473,324 Members | 2,535 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,324 software developers and data experts.

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 mvarEngineThread.Suspen
05 e.Cancel = MessageBox.Show(strQuitMessage, strQuitTitle,
MessageboxButtons.OKCancel) = DialogResult.Cance
06 mvarEngineThread.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 mvarEngineThread 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 3300
"Pi" <an*******@discussions.microsoft.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 mvarEngineThread.Suspend
05 e.Cancel = MessageBox.Show(strQuitMessage, strQuitTitle, _
MessageboxButtons.OKCancel) =
DialogResult.Cancel
06 mvarEngineThread.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 mvarEngineThread 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.Thread

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

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

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

Private Sub Form2_Closing( _
ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) _
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("", "", _
MessageBoxButtons.OKCancel) = DialogResult.Cancel
6: t.Resume()
7: 'Thread is terminated in _Closed event

End Sub

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

t.Abort()
End Sub

Private Sub Button2_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) 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.StringBuilder(400)
Next
System.Threading.Thread.Sleep(0)
Loop
End Sub

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

"Pi" <an*******@discussions.microsoft.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 mvarEngineThread.Suspend
05 e.Cancel = MessageBox.Show(strQuitMessage, strQuitTitle, _
MessageboxButtons.OKCancel) =
DialogResult.Cancel
06 mvarEngineThread.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 mvarEngineThread 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.Thread

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

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

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

Private Sub Form2_Closing( _
ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) _
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("", "", _
MessageBoxButtons.OKCancel) = DialogResult.Cancel
6: t.Resume()
7: 'Thread is terminated in _Closed event

End Sub

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

t.Abort()
End Sub

Private Sub Button2_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) 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*******@discussions.microsoft.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.StringBuilder(400)
Next
System.Threading.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*******@discussions.microsoft.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.StringBuilder(400
Nex
System.Threading.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*******@discussions.microsoft.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*******@discussions.microsoft.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.StringBuilder(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.StringBuilder(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.StringBuilder(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
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...
2
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.)...
8
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...
0
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; ...
20
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...
1
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...
4
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,...
2
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...
0
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...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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.