What is the best approach?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, friends,

We need to programm a .dll (C#) which will collect all selected files from
various locations, such as a DB, a file system, a VSS, etc. So, it may take
long time. I created a method GetAllFiles() to iterate/fetch each file, and
it works fine.

However, since this method is called from a Windows app (VC#), and users
want to see real time status for each file. What is the best approach to
implement this requirement? Create another thread in .dll to chech the
status, or raise an even, ....? Any ideas, reference papers, sample code, and
etc.?

Thanks a lot for your help...
 
What I would probably do is regularily raise an event. You can pass
informations in the parameters: an integer indicating the progress, and a
string to describe the current action (if needed). Then, in the Windows app,
you can catch that event to update the UI.

Etienne
 
Write the GetAllFiles() method so that it fires status update events,
call the method asynchronously using a new thread or by simply using
BeginInvoke() on a delegate and then in the event handler for status
update event update the UI as desired.

For a good discussion in various issues regarding Multi-Threaded
development refer to
http://www.yoda.arachsys.com/csharp/threads/
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/winforms06112002.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/winforms01232003.asp

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
 
Back
Top