Load data asynchronous with threads - InfoPath Dev
in

InfoPath Dev

Load data asynchronous with threads

Last post 05-31-2007 01:19 AM by rs200. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 05-25-2007 04:20 AM

    • rs200
    • Not Ranked
    • Joined on 02-27-2007
    • Germany
    • Posts 9

    Load data asynchronous with threads

    hello

    is it possible to load data asynchronous in IP 2003 ?

    i want to start a thread in the onload event, where i do some calculations

    when the thread has been finished, i want to set the result to a field in the template.

    but when i try to call thisxdocument.dom.selectsinglenode("'//my:field1).text i get a null result and my method ends.

    the thread and the mainform are working fine, but i can not access the thisxdocument object in the method which will be called when the thread ends.

     so what can i do?

  • 05-29-2007 01:42 PM In reply to

    Re: Load data asynchronous with threads

    Hi rs200,

    For this scenario you will undoubtably have to write some strange code.  I have never done this, so I can't tell you exactly, but you should do all of your data exchange between your business logic and the thread you want to run using straight C# objects and datatypes - don't try to access any of the implicit InfoPath objects that are created.  Also, try using the OnContextChange event to work around some of the problems with setting the value of the nodes.  This even fires almost continuously as a user is using InfoPath, so if you need to do some hand-offs, this is the place to do it.  Make sure you right a good check to see if you want to run the code though, and don't put much code in here, since it runs all the time.

     Good luck, and please let us know what you figure out!

    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 05-31-2007 01:19 AM In reply to

    • rs200
    • Not Ranked
    • Joined on 02-27-2007
    • Germany
    • Posts 9

    Re: Load data asynchronous with threads

    thanks matt for your answer,

     in the meantime I found a solution, which offers Microsoft

    http://msdn2.microsoft.com/en-us/library/aa948521(VS.80).aspx

    i have tested it and it works, but the problem is that, i have to use a (unvisible) windows form which brings sometimes errors when the template crashes during development.

    in this case the window will not be closed correctly and no new instances of this window can be created until i havn't closed and restarted all my VS and IP instances.

    i also have tested your proposal, it works too, but there i have the disadvantage i have to wait for an activity of the user when i want to update the data, but this is not a big problem because we have very active users :-)

     nevertheless i can say now it is possible to update the data asynchronous in a IP 2003 Form

    -> create a dataloader incance

    -> run the loading method in a thread

    -> check whether the data have been loaded with the window or OnContextChange and update the data

     

    BUT,  during my the delopment i have to look with one eye on the implemention of this solution in IP 2007 webbased Forms, because we want to switch to MOSS and IP 07 in Q3/Q4 this year.

    Hence i have tested both ways and both won't work. Because the OnContextChange event is not allowed in webbased forms and i can't use local data instances, i have to store data in the FormState, which i cant access from the thread.

     Any Ideas what i can do here?
     

     

     

     

     

     

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