wpf - Wait until a background worker is completed without locking out the main thread -


I am trying to run a background worker with a spinner running in the main thread and I would like to wait till then Unless the background worker is finished. Currently I have one or the other I have tried to use an auto reset event, but locking the main pouch so the spinner is not displayed is something similar to the auto reset event which locked the main UI

Here I have some code

  backgroundwalker_boker = new backgroundwork (); _bWorker.DoWork + = _bWorker_DoWork; _bWorker.RunWorkerCompleted + = _bWorker_RunWorker contains; AutoResetEvent = New AutoResetEvent (incorrect); _bWorker.RunWorkerAsync (); // Wait until the background worker is finished. Wait (); ... Private Zero _bWorker_DoWork (Object Sender, DoWorkEventArgs E) {// Spinner Wait SpinnerAdornerText = "Work"; IsWaitSpinnerVisible = True; ... ready(); } Private Zero contains _bWorker_RunWorker (Object Sender, RunWorkerCompletedEventArgs e) {IsWaitSpinnerVisible = false; ...}   

Any thoughts? Any help is welcome! thank you in advanced.

The full position to use a BackgroundWorker is that you complete it Do not 'Wait' to just remove AutoResetEvent and launch any that currently resides in RunWorkerAsync in _RunWorkerCompleted .

Alternatively you can see the work using parallel library and see that code to run as a continuation.

Finally, you can check for use of async CTP for .NET 4.0 in which the async / wait features behave virtually evenly how you want to write code.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -