0

I am new to C# .My job is to do an application which performs a task from step 1 to step 3 and show a GUI in front with info about the progress logged in it.Now i have the below options which would be the best and how can we do that in background.

1. Run the form (consisting of a rich text box) in background thread and put the  task     process in main.
2.Run the form in main pgm and put the task as a function running in background. 

Which of the above is the best approach. OR is there any thing better than the above . How can it be accomplished easily?

user2799127
  • 113
  • 2
  • 9

1 Answers1

0

I've never seen a GUI, that'd be controlled by a background thread because it needs to be responsive - event handling is being done on a main thread. In winforms for .net 4.0 you've got a BackgroundWorker class, with a ReportProgress() method raising proper event, which can be attended in your main form (most common use is to draw a progressbar) - that's the simpliest approach.

http://msdn.microsoft.com/en-us/library/cc221403%28v=vs.95%29.aspx

Similar topic on SO

Community
  • 1
  • 1
Tarec
  • 3,268
  • 4
  • 30
  • 47