Hanlding time consuming Operations in MFC
I have one MFC based legacy application, in which I cannot do much
modification as of now.
There is one functionality which involves Reading/Writing data from/to INI
file. It was written keeping in mind that the settings in ini files will
be very less in number. But now it has grown very huge.
So when executing this task, it takes about 30 minutes.
The problem is when user clicks on the application, the application get
lock and window windows show it's not responding dialog, asking if the
user need to wait for the application to respond or quit.
Now for me I can manage the time. But I don't want the window to show the
"Not Responding" behavior.
I think the problem is, that the main thread get busy in this process and
the UI hangs. I am not sure about this, as I am just guessing.
For handling this I created a Thread and calls this function inside it.
But in this thread function I could not call the AfxGetMainWnd();
function, as it is returning NULL.
It will be very helpful, if someone please let me know, how to handle such
cases (leaving the ideal case of not happening this)?
Also any nice advice is welcome.
My another though is also to put this code on a progress bar dialog.----
Thought on this are welcome.
Thanks
No comments:
Post a Comment