473,325 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Threaded modal progress window

bob
Hello,

In my appliction I try to pop up a progress dialog box while an
analysis is being run:

//method progress window
public void Run(IWin32Window parent)
{
Thread analysisThread = new Thread(new ThreadStart(runAnalysis));
analysisThread.Start();
ShowDialog(parent);
}

so you see that I've sent the analysis off on another thread. Now
that's fine except in some situaitions I get an OpenGL error. This
seems to be because the analysis code is firing off the odd event,
some of which cause the application behind the modal progress box to
update itself. This doesn't seem very safe - the main loop updating
the main window + events from the new thread.

How can I fix this problem?

Please help, I'm stuck.

Thanks
Nov 16 '05 #1
2 6412
Bob,

In order to get around this, you have to check in your event handlers
whether or not you are on the UI thread or not. The easiest way to do this
is to call the InvokeRequired property on a control on the form, or the form
itself. If it returns true, then you have to call the Invoke method to
perform any kind of action that might affect the UI. You would pass a
delegate to the method you want to call, as well as the parameters to pass
to that method.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"bob" <bo**********@hotmail.com> wrote in message
news:b0*************************@posting.google.co m...
Hello,

In my appliction I try to pop up a progress dialog box while an
analysis is being run:

//method progress window
public void Run(IWin32Window parent)
{
Thread analysisThread = new Thread(new ThreadStart(runAnalysis));
analysisThread.Start();
ShowDialog(parent);
}

so you see that I've sent the analysis off on another thread. Now
that's fine except in some situaitions I get an OpenGL error. This
seems to be because the analysis code is firing off the odd event,
some of which cause the application behind the modal progress box to
update itself. This doesn't seem very safe - the main loop updating
the main window + events from the new thread.

How can I fix this problem?

Please help, I'm stuck.

Thanks

Nov 16 '05 #2
bob
Thanks Nicholas,

that worked a treat
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:<#o**************@TK2MSFTNGP09.phx.gbl>...
Bob,

In order to get around this, you have to check in your event handlers
whether or not you are on the UI thread or not. The easiest way to do this
is to call the InvokeRequired property on a control on the form, or the form
itself. If it returns true, then you have to call the Invoke method to
perform any kind of action that might affect the UI. You would pass a
delegate to the method you want to call, as well as the parameters to pass
to that method.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"bob" <bo**********@hotmail.com> wrote in message
news:b0*************************@posting.google.co m...
Hello,

In my appliction I try to pop up a progress dialog box while an
analysis is being run:

//method progress window
public void Run(IWin32Window parent)
{
Thread analysisThread = new Thread(new ThreadStart(runAnalysis));
analysisThread.Start();
ShowDialog(parent);
}

so you see that I've sent the analysis off on another thread. Now
that's fine except in some situaitions I get an OpenGL error. This
seems to be because the analysis code is firing off the odd event,
some of which cause the application behind the modal progress box to
update itself. This doesn't seem very safe - the main loop updating
the main window + events from the new thread.

How can I fix this problem?

Please help, I'm stuck.

Thanks

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: amith | last post by:
Hi, I have a javascript, calendar.js which i use to enable my client to select the date. This calendar pops up on the click of a gif image. But the problem is that this poped up window is not...
2
by: Matt | last post by:
I want to know how to submit the form data to a modal dialog window? The following is page1.asp, and when the user clicks submit button, it will post the form data to page2.asp by opening a new...
1
by: gopal srinivasan | last post by:
I need to know how to close a parent modal window when child modal window opens, also i need to know the syntax for writing document on the modal window on the fly, like what we do in case of...
2
by: Keith Rebello | last post by:
I am writing a program that analyzes a reinforced concrete column section. The main form has an "Analysis" menu item that calls the main analysis routines in a ColumnSection class. It also opens a...
3
by: | last post by:
Hi to everybody, I have the following situation: I have a lengthy operation inside a desktop application - something that has to be executed on the main thread of the app (this is a must) .......
4
by: Todd | last post by:
I've got a situation where I need to display a modal dialog from within a background processing thread. The problem I'm having is that it needs to display as a modal window to the thread's parent...
2
by: sthrudel | last post by:
Hi! I'm working on a web application in Asp.net and what I would like to have is a cross borwser modal dialog which accepts user's input. I would like to catch what the user clicked on the...
0
by: sskala | last post by:
Hi, Hope you might have seen the new version of yahoo mail. When you click an attachment in your mail, it pops up a window which shows the progress of SCAN. The user won't be able to close it or...
2
by: melryin | last post by:
Hi, I'm a novice in C#. I wrote a program to export data from datagridview. While exporting, a pop-up window shows the progress of file exporting. The code is as follow: BackgroundWorker...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.