Post message to event queue [modified]
-
Hi, Here is a situation. I need to perform long operation in UI thread. I must do it in UI thread, cause algorithm uses 3rdparty resources managed by UI thread. And these resources are not thread safe. So, I do it in UI thread. Because operation is very long I would like to not block the application. What I want is: 1) Interrupt algorithm execution. Store some message in message queue that algorithm must be resolved. 2) Application process all pending events in the queue (key eents, mouse events, draw events etc). 3) I get the the control again in some my handler. (All in the same thread) Similar to what I would do with PostMessage. Like a System::Windows::Forms::Timer with 0 interval (which is not allowed). How can I do that? And here is another detail: I'm doing all this NOT from UI control class. In fact I do it in static member function. But I'm in main(UI) thread. Thanks. /////////////////////////////////////////////////////////////////////////////// Found a resolution. System::Windows::Threading::Dispatcher class does exactly what I need. And it doesnt require a UI control (like COntrol::BeginInvoke). Works perfect. Theme closed.
modified on Wednesday, February 23, 2011 8:47 AM
-
Hi, Here is a situation. I need to perform long operation in UI thread. I must do it in UI thread, cause algorithm uses 3rdparty resources managed by UI thread. And these resources are not thread safe. So, I do it in UI thread. Because operation is very long I would like to not block the application. What I want is: 1) Interrupt algorithm execution. Store some message in message queue that algorithm must be resolved. 2) Application process all pending events in the queue (key eents, mouse events, draw events etc). 3) I get the the control again in some my handler. (All in the same thread) Similar to what I would do with PostMessage. Like a System::Windows::Forms::Timer with 0 interval (which is not allowed). How can I do that? And here is another detail: I'm doing all this NOT from UI control class. In fact I do it in static member function. But I'm in main(UI) thread. Thanks. /////////////////////////////////////////////////////////////////////////////// Found a resolution. System::Windows::Threading::Dispatcher class does exactly what I need. And it doesnt require a UI control (like COntrol::BeginInvoke). Works perfect. Theme closed.
modified on Wednesday, February 23, 2011 8:47 AM
progDes wrote:
I must do it in UI thread, cause algorithm uses 3rdparty resources managed by UI thread. And these resources are not thread safe. So, I do it in UI thread
There may be a way, but apparently there's no will. More information would be helpful.
-
Hi, Here is a situation. I need to perform long operation in UI thread. I must do it in UI thread, cause algorithm uses 3rdparty resources managed by UI thread. And these resources are not thread safe. So, I do it in UI thread. Because operation is very long I would like to not block the application. What I want is: 1) Interrupt algorithm execution. Store some message in message queue that algorithm must be resolved. 2) Application process all pending events in the queue (key eents, mouse events, draw events etc). 3) I get the the control again in some my handler. (All in the same thread) Similar to what I would do with PostMessage. Like a System::Windows::Forms::Timer with 0 interval (which is not allowed). How can I do that? And here is another detail: I'm doing all this NOT from UI control class. In fact I do it in static member function. But I'm in main(UI) thread. Thanks. /////////////////////////////////////////////////////////////////////////////// Found a resolution. System::Windows::Threading::Dispatcher class does exactly what I need. And it doesnt require a UI control (like COntrol::BeginInvoke). Works perfect. Theme closed.
modified on Wednesday, February 23, 2011 8:47 AM
-
If this window will be in the same thread as main UI thread (which is requirement) - it will block application anyway.
-
Ok, I didn't realise it had to be in the main UI thread. If you can host the 3rd party resources in a separate UI thread, you may find an answer here
"You get that on the big jobs."