473,473 Members | 4,189 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Modeless Dialog hangs

2 New Member
I am trying to create a modeless dialog from an event thread not generated from the original form. When created in one of the event handlers from the form, the dialog works properly. Also it works properly if it is a modal dialog.

I made this little example that will just pop up a modeless dialog (form2) after a second.
Here's some code....
Expand|Select|Wrap|Line Numbers
  1.  
  2. System.Timers.Timer timer = new System.Timers.Timer();
  3.         bool timer1 = false;
  4. Form2 c;
  5.  
  6. public Form1()
  7.         {
  8.             InitializeComponent();
  9.             timer.Interval = 1000;
  10.             timer.Elapsed += new System.Timers.ElapsedEventHandler(timertick);
  11.             timer.Start();
  12.         }
  13.         void timertick(object sender, System.Timers.ElapsedEventArgs e)
  14.         {
  15.             if (!timer1)
  16.             {
  17.                 ProcessEvent();
  18.                 timer1 = true;
  19.                 timer.Enabled = false;
  20.             }
  21.             else
  22.             {
  23.                 timer.Stop();
  24.             }
  25.         }
  26.  
  27.   private void ProcessEvent()
  28.         {
  29.             c = new Form2();
  30.             c.Show();                    
  31.          }
Apr 20 '10 #1
3 3845
tlhintoq
3,525 Recognized Expert Specialist
TIP: When you first created your question you were asked to wrap your code with [code] tags.

It really does help a bunch. Look how much easier it is to read now that someone has done it for you. Its the button with a '#' on it. More on tags. They're cool. Check'em out.


UPDATE: You really did try and were very close. Sorry if my standard copy/paste reply to people who don't try at all sounded a bit cold. You had closed with \code instead of /code and the site parser didn't like the \ in place of / - No big deal, easy fixed
Apr 20 '10 #2
tlhintoq
3,525 Recognized Expert Specialist
I'm not sure I follow the exact nature of the problem.

Modeless Dialog hangs
by "hangs" are you saying that instance 'c' of Form2 opens, but doesn't close... opens but doesn't respond to user interaction... doesn't open...

I am trying to create a modeless dialog from an event thread not generated from the original form.
There is nothing in your code having to do with threading.
Apr 20 '10 #3
btotten
2 New Member
I fixed the issue by adding
Expand|Select|Wrap|Line Numbers
  1. private delegate void ModelessDialog(Arguments args);
  2.  
and changing
Expand|Select|Wrap|Line Numbers
  1. private void ProcessEvent()
  2. {
  3. if (this.InvokeRequired)
  4.             {
  5.                 this.Invoke(new ModelessDialog(ProcessEvent), null);
  6.             }
  7. else
  8. {
  9. c = new Form2(); 
  10.             c.Show(); 
  11. }
  12. }
  13.  
Thanks for the help.
Apr 20 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Rikkert | last post by:
I can't get my custom-made modeless dialog box (Visual C++.net Win32) to respond to clicking the close button or pressing Alt-F4. I am using the IsDialogMessage to check if messages are for my...
1
by: Carmine | last post by:
I'm currently writing a small program that churns on a repetitive task while displaying a progress & cancel modeless dialog. I've been having problems due to threadlocking, and I was wondering if...
0
by: Andrew | last post by:
I get a Null Reference Exception if I close a modeless form (that is, a form displayed using Show()) when a selection is made from a ComboxBox. If the form is modal (displayed using ShowDialog())...
2
by: Legendary Pansy | last post by:
Hello, I'm trying to accomplish the impossible by trying to do something equivalent of this example found here http://www.c-sharpcorner.com/Code/2003/Dec/DialogTutorial.as Starting with "Listing...
1
by: andrew | last post by:
Hi there, I'm having a problem with a modeless form in my app. I have a main form in my app and a socket that waits on data from a server (I use BeginReceive/EndReceive for that) and when I...
2
by: proit_123 | last post by:
I am working on a windows forms application and have the following requirement. · I need to display a modeless dialog from the main form. o This allows user to continue to work with the...
8
by: proit_123 | last post by:
I am working on a windows forms application and have the following requirement. I have two projects in my application Project A and Project B. And Project A has the reference of Project B. I...
0
by: Ralstoj | last post by:
Hi I am programing in Autocad with VB Autodesk have not given users access to new note function in Autocad CIVIL3d API. I am trying to work round this by creating notes using the sendkey...
0
by: Sin Jeong-hun | last post by:
I've found that if a MessageBox (called by alert/confirm from Javascript) or a web page modeless dialog is popped up, I cannot call Navigate of the WebBrowser control. If I do, a COM exception...
3
by: DoB | last post by:
What is the preferred way to refresh modeless dialogs? I am using the modeless dialog that shows a progress of a sequential process. The dialog class has nonvisual properties containg the...
0
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...
0
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,...
0
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...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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...

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.