Using Data Connections in a Separate Thread - InfoPath Dev
in

InfoPath Dev

Using Data Connections in a Separate Thread

Last post 01-08-2015 07:52 AM by Mark_H. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 01-08-2015 07:52 AM

    • Mark_H
    • Not Ranked
    • Joined on 01-08-2015
    • Posts 1

    Using Data Connections in a Separate Thread

    Hello there,

    I've been struggling with this particular issue for a couple days now and I have had an awful time trying to find a confirmation that this should or should not work.

    I am using the CAML method to submit data from an InfoPath 2013 form to various SharePoint lists. I also query data from those lists via a number of data connections I have setup in the InfoPath GUI. The requests over our VPN are taking a great deal of time whenever I open a data connection and query or submit data. I'm trying to improve the user experience by potentially executing the data connections in a separate thread. I am new to threading so I may just be making a simple mistake but I have been able to use threads successfully in a couple other simple scenarios.

    I have tried a number of threading methods but here is the current example of what I have setup:

    I have a separate class I'm using to pass arguments to my separate thread which my current implementation uses a BackgroundWorker.

    (I declare a new FormCode member variable at the top of Form code that will hold the thread argument details)

    public ThreadedQueryInfo queryInfo = new ThreadedQueryInfo();

     

    In a subsequent method I create and call a BackgroundWorker:

    _queryBW = new BackgroundWorker();

    _queryBW.DoWork += _queryBW_StartQuery;

    _queryBW.RunWorkerAsync(queryInfo);

     

    Here is the method that gets executed by the  BackgroundWorker:

    private void _queryBW_StartQuery(object sender, DoWorkEventArgs e)
    {
    ThreadedQueryInfo info = (ThreadedQueryInfo)e.Argument;

    DataConnections[info.sharepointList].Execute();

    info.complete = true;
    }

     

    When I attempt to execute this query, I am getting  the following exception:

    HResult=-2146233079
      Message=Operation is not valid due to the current state of the object.
      Source=Microsoft.Office.InfoPath.Client.Internal.Host
      StackTrace:
           at Microsoft.Office.InfoPath.Internal.MomExceptionHelper.ExecuteDataConnectionAction(XmlFormHost formHost, OMCall d)
           at Microsoft.Office.InfoPath.Internal.SharePointListAdapterRWQueryAdapterHost.Execute()
           at Solution_Requests_IPForm_ver12.FormCode._queryBW_StartQuery(Object sender, DoWorkEventArgs e) in c:\...\...\Local\Temp\Vsta\505864c8d93a44e49f3de6eaa92cd0d5\FormCode.cs:line 840
           at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
           at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)

     

    The Status attribute of the exception shows: System.Net.WebExceptionStatus.UnknownError and the Response shows: null.

    I was looking around and noticed this article: http://msdn.microsoft.com/en-us/library/office/aa948521%28v=office.15%29.aspx which mentions particular dll's that may be a problem but I am not using the the ones mentioned.

    I was wondering if anyone here might have some experience with executing data connections from another thread or know that it is not supported.

    I apologize if I've left out any crucial information needed. Thank you in advance for your time!

Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.