473,770 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(IWin32Windo w parent)
{
Thread analysisThread = new Thread(new ThreadStart(run Analysis));
analysisThread. Start();
ShowDialog(pare nt);
}

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 6435
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.co m

"bob" <bo**********@h otmail.com> wrote in message
news:b0******** *************** **@posting.goog le.com...
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(IWin32Windo w parent)
{
Thread analysisThread = new Thread(new ThreadStart(run Analysis));
analysisThread. Start();
ShowDialog(pare nt);
}

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.c om> wrote in message news:<#o******* *******@TK2MSFT NGP09.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.co m

"bob" <bo**********@h otmail.com> wrote in message
news:b0******** *************** **@posting.goog le.com...
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(IWin32Windo w parent)
{
Thread analysisThread = new Thread(new ThreadStart(run Analysis));
analysisThread. Start();
ShowDialog(pare nt);
}

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
12531
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 modal in nature(i do not want the user to go the parent page unless he selects some date in the calendar popup). In the javascript calendar.js he has used window.open() function to pop up the window. i just want to know whether we have any...
2
3884
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 window. But I want modal dialog window, any ideas?? <form action="page2.asp" method="post" target="_blank"> <input type="text" name="username"> <input type="submit" name="submit"> </form>
1
3373
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 normal window. Actually, I tried to close the parent window from the child modal window using parent.close syntax in onload event in child modal window. It actually closes the parent modal window, but the child modal window is not opened, why it is...
2
1286
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 modal form containing a progress bar which shows the progess of the analysis. i.e. FormProgress.ShowDialog ColumnSection.Analyze In the ColumnSection class I raise an event that updates the progress: RaiseEvent OverallProgress(iProgress)
3
1374
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) .... server.callLennghtyOperation(...) ....
4
1371
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 GUI app. When I try this I get a pseudo-modal dialog (more like a top-level window)... the dialog is always on top of the parent app's window, but the user can still access the parent window and its controls. Is there any way to accomplish...
2
3686
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 dialog. To be more specific I want to have a confirmation dialog that is shown when a user clicks on a Delete button (which deletes some values from database). If Yes is pressed the delete action is processed otherwise modal dialog is closed.
0
1375
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 access yahoo mail until this process is complete and the "Done" button is enabled. This is like a modal dialog without controlbox (no minimize, maximize and close buttons). I got a similar requirement in my project. When the user clicks the...
2
2533
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 bgw = new BackgroundWorker(); bgw.DoWork += delegate {
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10257
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10099
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10037
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8931
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.