473,800 Members | 2,950 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MessageBox.Show hangs execution

Pi
I have an MDI parent with one or more children forms. Each child form has an engine thread that processes data. The child form's _Closing event is roughly

01 Private Sub frmConvertable_ Closing(sender, e
02 'Show the form (other MDI children may be on top
03 Me.Activate(
04 mvarEngineThrea d.Suspen
05 e.Cancel = MessageBox.Show (strQuitMessage , strQuitTitle,
MessageboxButto ns.OKCancel) = DialogResult.Ca nce
06 mvarEngineThrea d.Resum
07 'Thread is terminated in _Closed even
08 End Su

When I run the application and hold down Esc to continually call the closing event and cancel the messagebox (resume processing), after a few seconds the application hangs. Breaking into the debugger shows that line 05 is highlighted green

If I comment out the mvarEngineThrea d suspend and resume (lines 04 and 06) the application never hangs when I hold down Esc

Can anybody offer an explaination for this?
Nov 20 '05 #1
7 3339
"Pi" <an*******@disc ussions.microso ft.com> schrieb
I have an MDI parent with one or more children forms. Each child
form has an engine thread that processes data. The child form's
_Closing event is roughly:

01 Private Sub frmConvertable_ Closing(sender, e)
02 'Show the form (other MDI children may be on top)
03 Me.Activate()
04 mvarEngineThrea d.Suspend
05 e.Cancel = MessageBox.Show (strQuitMessage , strQuitTitle, _
MessageboxButto ns.OKCancel) =
DialogResult.Ca ncel
06 mvarEngineThrea d.Resume
07 'Thread is terminated in _Closed event
08 End Sub

When I run the application and hold down Esc to continually call the
closing event and cancel the messagebox (resume processing), after a
few seconds the application hangs. Breaking into the debugger shows
that line 05 is highlighted green.

If I comment out the mvarEngineThrea d suspend and resume (lines 04
and 06) the application never hangs when I hold down Esc.

Can anybody offer an explaination for this?


Did you set the cancelbutton property of the MDI child to close the child
using ESC? That's what I assumed to test the situation. I could not
reproduce the problem (VB 2003). I held down ESC several seconds.

This is my code in the child window:

Dim t As Threading.Threa d

Private Sub Button1_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button1.Click

t = New Threading.Threa d(AddressOf threadstart)
t.Start()
End Sub

Private Sub threadstart()
Do
Threading.Threa d.Sleep(100)
Loop
End Sub

Private Sub Form2_Closing( _
ByVal sender As Object, _
ByVal e As System.Componen tModel.CancelEv entArgs) _
Handles MyBase.Closing

2: 'Show the form (other MDI children may be on top)
3: Me.Activate()
4: t.Suspend()
5: e.Cancel = MessageBox.Show ("", "", _
MessageBoxButto ns.OKCancel) = DialogResult.Ca ncel
6: t.Resume()
7: 'Thread is terminated in _Closed event

End Sub

Private Sub Form2_Closed( _
ByVal sender As Object, ByVal e As System.EventArg s) _
Handles MyBase.Closed

t.Abort()
End Sub

Private Sub Button2_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button2.Click

Me.Close()
End Sub
After opening the child, I clicked button1 to start the thread, then held
down Esc.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
Pi
Armin,

Your code looks very similiar to my test code (VB 2003). The only difference I can see is the threading procedure:

Public Sub ThreadProc()
Do
For i As Integer = 0 To 1000
Dim a As New System.Text.Str ingBuilder(400)
Next
System.Threadin g.Thread.Sleep( 0)
Loop
End Sub

----- Armin Zingler wrote: -----

"Pi" <an*******@disc ussions.microso ft.com> schrieb
I have an MDI parent with one or more children forms. Each child
form has an engine thread that processes data. The child form's
_Closing event is roughly:
01 Private Sub frmConvertable_ Closing(sender, e)

02 'Show the form (other MDI children may be on top)
03 Me.Activate()
04 mvarEngineThrea d.Suspend
05 e.Cancel = MessageBox.Show (strQuitMessage , strQuitTitle, _
MessageboxButto ns.OKCancel) =
DialogResult.Ca ncel
06 mvarEngineThrea d.Resume
07 'Thread is terminated in _Closed event
08 End Sub
When I run the application and hold down Esc to continually call the

closing event and cancel the messagebox (resume processing), after a
few seconds the application hangs. Breaking into the debugger shows
that line 05 is highlighted green.
If I comment out the mvarEngineThrea d suspend and resume (lines 04

and 06) the application never hangs when I hold down Esc.
Can anybody offer an explaination for this?


Did you set the cancelbutton property of the MDI child to close the child
using ESC? That's what I assumed to test the situation. I could not
reproduce the problem (VB 2003). I held down ESC several seconds.

This is my code in the child window:

Dim t As Threading.Threa d

Private Sub Button1_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button1.Click

t = New Threading.Threa d(AddressOf threadstart)
t.Start()
End Sub

Private Sub threadstart()
Do
Threading.Threa d.Sleep(100)
Loop
End Sub

Private Sub Form2_Closing( _
ByVal sender As Object, _
ByVal e As System.Componen tModel.CancelEv entArgs) _
Handles MyBase.Closing

2: 'Show the form (other MDI children may be on top)
3: Me.Activate()
4: t.Suspend()
5: e.Cancel = MessageBox.Show ("", "", _
MessageBoxButto ns.OKCancel) = DialogResult.Ca ncel
6: t.Resume()
7: 'Thread is terminated in _Closed event

End Sub

Private Sub Form2_Closed( _
ByVal sender As Object, ByVal e As System.EventArg s) _
Handles MyBase.Closed

t.Abort()
End Sub

Private Sub Button2_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button2.Click

Me.Close()
End Sub
After opening the child, I clicked button1 to start the thread, then held
down Esc.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
Nov 20 '05 #3
"Pi" <an*******@disc ussions.microso ft.com> schrieb

Your code looks very similiar to my test code (VB 2003). The only
difference I can see is the threading procedure:

Public Sub ThreadProc()
Do
For i As Integer = 0 To 1000
Dim a As New System.Text.Str ingBuilder(400)
Next
System.Threadin g.Thread.Sleep( 0)
Loop
End Sub

With this code I can reproduce the problem! I'm gonna have a look at it.

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4
Pi

----- Armin Zingler wrote: ----

"Pi" <an*******@disc ussions.microso ft.com> schrie
Your code looks very similiar to my test code (VB 2003). The onl

difference I can see is the threading procedure:
Public Sub ThreadProc(

D
For i As Integer = 0 To 100
Dim a As New System.Text.Str ingBuilder(400
Nex
System.Threadin g.Thread.Sleep( 0
Loo
End Su

With this code I can reproduce the problem! I'm gonna have a look at it

--
Armi

http://www.plig.net/nnq/nquote.htm
http://www.netmeister.org/news/learn2quote.htm

Thanks for that Armin. Can you let me know if you find anything?
Nov 20 '05 #5
"Pi" <an*******@disc ussions.microso ft.com> schrieb
Thanks for that Armin. Can you let me know if you find anything?


Thanks for reminding me.....
--
Armin

Nov 20 '05 #6
"Pi" <an*******@disc ussions.microso ft.com> schrieb

Thanks for that Armin. Can you let me know if you find
anything?

First I thought it might be a garbage collection issue because constantly
creating new stringbuilders should make the GC work heavily. On the other
side, there is no CPU usage when the app is locked. Then I had a look at the
callstack, the threads, the disassembly and the IL code - but I don't know
much more now, I mean, I didn't find the problem.

I tried this:
Dim a As New System.Text.Str ingBuilder(400)
a = Nothing
GC.Collect()

Now the app isn't locked anymore. Without it, I think there must be a kind
of dead-lock anywhere. Anybody else's got an explanation?
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #7
Pi
First I thought it might be a garbage collection issue because constantly
creating new stringbuilders should make the GC work heavily. On the other
side, there is no CPU usage when the app is locked. Then I had a look at the
callstack, the threads, the disassembly and the IL code - but I don't know
much more now, I mean, I didn't find the problem.

I tried this:
Dim a As New System.Text.Str ingBuilder(400)
a = Nothing
GC.Collect()

Now the app isn't locked anymore. Without it, I think there must be a kind
of dead-lock anywhere. Anybody else's got an explanation?
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
I tried your code:

Dim a As New System.Text.Str ingBuilder(400)
a = Nothing
GC.Collect()

After holding down Esc for over 15 secs the app then hung itself. I'm baffled with this one.
Nov 20 '05 #8

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

Similar topics

11
541
by: Rich Tasker | last post by:
I have a strange situation. A simple call to MessageBox.Show("XXX", "YYY") does not display the message in the messagebox with a visible font. Based on the content of the messagebox, the box sizes properly so I know there is a message in there. I also found a keyboard shortcut where <ctrl>+<insert> will copy the contents of the messagebox to the clipboard in plain text. I see my messagebox text in the clipboard contents but not in the...
2
30165
by: Dennis C. Drumm | last post by:
This is a restatement of an earlier post that evidently wasn't clear. I am building a custom MessageBox dialog that has, among other things, a few new button options (yes to all, no to all, etc.) and would like to make the dialog look and act like the standard MessageBox. Therefore, I would like to put in the message section the same type of icons found in the MessageBox dialog, such as MessageBoxIcon.Exclamation. In another post here I had...
8
2450
by: Saso Zagoranski | last post by:
Hi! I'm trying to make my own MessageBox... What I would like to know is, how the MessageBox class is implemented? I could have something like: new MyMessageBox().ShowDialog(); but I would like the solution used by MessageBox, where you call the static Show() method, which returns a DialogResult value...
0
4092
by: alex_f_il | last post by:
The class centers MessageBox inside the parent rectangle. Enjoy! using System; using System.Windows.Forms; using System.Text; using System.Drawing; using System.Runtime.InteropServices; namespace Utils {
20
8916
by: Peter E. Granger | last post by:
I'm having a strange problem (or at least it seems strange to me) trying to display a MessageBox in a VC++ .NET forms application. If I put the call to MessageBox::Show in the form's .h file, it works just fine. If I put the call in the .cpp file, I get the following two errors: error C2653: 'MessageBoxA': is not a class or namespace name error C2660: 'System::Windows::Forms::Control::Show': function does not take
1
1694
by: Pi | last post by:
I have an MDI parent with one or more children forms. Each child form has an engine thread that processes data. The child form's _Closing event is roughly 01 Private Sub frmConvertable_Closing(sender, e 02 'Show the form (other MDI children may be on top 03 Me.Activate( 04 mvarEngineThread.Suspen 05 e.Cancel = MessageBox.Show(strQuitMessage, strQuitTitle, MessageboxButtons.OKCancel) = DialogResult.Cance 06 ...
4
2006
by: Larry Woods | last post by:
I have a Messagebox that looks like: MessageBox.Show("There are pending changes for this patient. Do you want to continue to close?", "Pending Changes", MessageBoxButtons.YesNo, MessageBoxIcon.Question) When I execute the Messagebox.Show, then press either 'Yes' or 'No' I get 25 of the following Messageboxes: "incorrect syntax near the keyword WHERE"
2
2693
by: Pierre Rouleau | last post by:
Hi all, I have a consistent test case where os.popen3() hangs in Windows. The system hangs when retrieving the lines from the child process stdout. I know there were several reports related to os.popen3() hanging under Windows in this group before. I stumbled on a case where a piece of code works in some occasions and hangs consistently given different data. It performs exactly the same on 3 different computers running Windows:
0
1889
by: Rilly | last post by:
Anyone use PowerMovielist here? I have the 0.14 beta version. Do you have a problem where some shows you search for cause the fetch to hang ? I'm pulling my hair out on this.. For example, I search for Funky, and it comes up with all the hits.. I search for Funky Phantom, and it hangs for whatever amount of seconds i have the script maximum execution time set to, then i get this error Fatal error: Maximum execution time of 30 seconds...
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
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
10501
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
10273
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
10250
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
10032
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
6811
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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

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.