CChildFrame in separate thread
-
I have a MDI app, with view based on CHtmlView. Is there any way to launch every CChildFrame in separate thread ? If yes, how can I do that ? I search on internet for this, but I have found nothing ...
The frames belong to the GUI and should be therefore executed in the GUI (main) thread. I even don't think that it is possible to run the child frames in another thread due to the relationship to the main frame, and the views. Even if it is possible, it would be a nightmare to make it all thread safe. But you can execute specific operations within the child frames or the views in separate threads. A common method is to use worker threads for longer running jobs. Because such threads can not directly access (MFC) UI elements, they have to post (user defined) messages to update UI elements.
-
The frames belong to the GUI and should be therefore executed in the GUI (main) thread. I even don't think that it is possible to run the child frames in another thread due to the relationship to the main frame, and the views. Even if it is possible, it would be a nightmare to make it all thread safe. But you can execute specific operations within the child frames or the views in separate threads. A common method is to use worker threads for longer running jobs. Because such threads can not directly access (MFC) UI elements, they have to post (user defined) messages to update UI elements.
My task is to run some specific html pages, but sending some forms inside these page is taking a little more time, and there is 8-10 html pages ... I was thinking that running every child frame in separate thread would be a good solution ... but I guess is not ... hmm ... I don't know how to shrink the time when these html pages work their tasks ...
-
My task is to run some specific html pages, but sending some forms inside these page is taking a little more time, and there is 8-10 html pages ... I was thinking that running every child frame in separate thread would be a good solution ... but I guess is not ... hmm ... I don't know how to shrink the time when these html pages work their tasks ...
You can still use threads to do the work and provide some kind of wait indication (cursor, status line, or self closing notification / progress window). The advantage of using threads is that the GUI is not blocked and the user can do other operations meanwhile. But using threads is not making something that requires an amount of time running faster (besides splitting the work and letting multiple threads perform the work in parallel). It just allows doing something else meanwhile.
-
You can still use threads to do the work and provide some kind of wait indication (cursor, status line, or self closing notification / progress window). The advantage of using threads is that the GUI is not blocked and the user can do other operations meanwhile. But using threads is not making something that requires an amount of time running faster (besides splitting the work and letting multiple threads perform the work in parallel). It just allows doing something else meanwhile.
You are perfectly right. Here is the scenario: I should start 8 CHtmlViews, every one of them with a specific web address, and do a login form. Now, every login task, take 3-4 seconds. If a do this for every 8 pages, the time until all 8 pages complete the login is ~30, 35 seconds, but, most important, the main thread, the GUI thread is blocked. That is why I am trying to run every CHtmlView on separate thread, not because the login task is taken less time, but because is not block the main GUI thread ...
-
You are perfectly right. Here is the scenario: I should start 8 CHtmlViews, every one of them with a specific web address, and do a login form. Now, every login task, take 3-4 seconds. If a do this for every 8 pages, the time until all 8 pages complete the login is ~30, 35 seconds, but, most important, the main thread, the GUI thread is blocked. That is why I am trying to run every CHtmlView on separate thread, not because the login task is taken less time, but because is not block the main GUI thread ...
Put the communication tasks into there own threads and display a place holder in the view meanwhile. Once the communictaion is done, update the view with the data received in the background.
-
Put the communication tasks into there own threads and display a place holder in the view meanwhile. Once the communictaion is done, update the view with the data received in the background.
-
If have not used
CHtmlView
so far but I'm quite sure that the networking is done in a separate thread and there are notification messages informing you when a page has been loaded. Anything else would make no sense because a large download would block your GUI. If your GUI is blocked, you are probably waiting somewhere inside a loop instead of handling notifications. -
If have not used
CHtmlView
so far but I'm quite sure that the networking is done in a separate thread and there are notification messages informing you when a page has been loaded. Anything else would make no sense because a large download would block your GUI. If your GUI is blocked, you are probably waiting somewhere inside a loop instead of handling notifications.This is a good news. So, I will launch view after view to do a login to see how is moving my GUI ... if I think well, there is some methods on this CHtmlView which reveal that all tasks inside html gui is made somewhere in backside (I guess):
CHtmlView::OnBeforeNavigate2
CHtmlView::OnDocumentComplete
CHtmlView::OnDownloadBegin
CHtmlView::OnDownloadComplete
CHtmlView::OnNavigateComplete2
CHtmlView::OnNavigateError
CHtmlView::OnUpdateUI
// ans so on ...