multithreading - C# need 2 threads for long execution -


i have program loads data sharepoint site. loads txt files, xml files, etc. of these "load" actions can take lot of time because of user's connectivity sharepoint. therefore whole windows form ui gets unresponsive until data loaded.

so know how can create thread "retrieval" of information while whole windows forms ui still works , operative.

you have few options. i'm not going provide exact code of them, but, provide research topics.

you can use backgroundworker, task.run() or manage own threading doing thread.start(). need fire off event when downloading finished? if so, can this:

var task = new task(() => dosomething()); task.continuewith(() => signaldone(), taskscheduler.fromcurrentsynchronizationcontext()); task.run(); 

the continuewith , taskscheduler.fromcurrentsynchronizationcontext ensure signaling done on ui thread minimize race conditions. you're on own if you're doing databinding being populated.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -