1

I am trying to develop a multithreaded plugin in petrel where my algorithm runs in 2 separate threads. The plugin seems to work fine except I cant find any method to update the progress bar.

using Invoke does not update the progress bar(c# progress bar) and my UI completely freezes during execution.

Is there any way to update the progress bar (Either petrel progress or standard progresss bar) from another thread when the algo is running?

Thanks

user938972
  • 81
  • 1
  • 4

2 Answers2

4

Use Slb.Ocean.Petrel.PetrelLogger.NewAsyncProgress(String, ProgressType) or NewAsyncProgress(String, ProgressType, AsyncProgressCanceledCallback, Object) to update the progress bar from background threads.

Evgeny
  • 665
  • 4
  • 14
  • Do I need to declare it in the main thread or the worker thread? Actually I have a number of threads which execute the same function and they run simultaneously by spawning threadpool from ExecuteSimple(). Do I need to pass the progress bar as an argument to the thread? – user938972 Oct 06 '11 at 16:05
2

Control.Invoke only works if the message processing of the UI thread is not blocked. If your main thread is waiting for the result you need to periodically call Application.DoEvents.

Regarding Petrel progress bars: Typically simple progress bar is used if no user interaction is allowed, Petrel is blocked until the operation is completed while one or more async progress bar is used if the end user starts some operation but he is able to work while the operation is running at the background.

If you choose the first approach you can e.g. store the progress in a variable which is visible to each thread (make sure the variable is properly locked) and the main thread can periodically read that variable in a loop and update progress accordingly.

balazsm
  • 41
  • 2