[Mono-bugs] [Bug 332206] New: System.Threading. Timer stop on excecption in callback method
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Tue Oct 9 10:21:27 EDT 2007
https://bugzilla.novell.com/show_bug.cgi?id=332206
Summary: System.Threading.Timer stop on excecption in callback
method
Product: Mono: Class Libraries
Version: 1.2
Platform: Other
OS/Version: Other
Status: NEW
Severity: Major
Priority: P5 - None
Component: CORLIB
AssignedTo: mono-bugs at ximian.com
ReportedBy: informatique.internet at fiducial.fr
QAContact: mono-bugs at ximian.com
Found By: ---
On mono, if you use the System.Threading.Timer and the callback method raise an
exception, the timer is stopped... and no more event is generated
On MS.NET, it continues, the timer is still alive...
Test case :
// project created on 04/10/2007 at 09:42
using System;
using System.Threading;
namespace TestEscape
{
class MainClass
{
public static void Main(string[] args)
{
System.Threading.Timer
tmrThreadingTimer = new
System.Threading.Timer(new
TimerCallback(tmrThreadingTimer_TimerCallback),
null, System.Threading.Timeout.Infinite, 1000);
tmrThreadingTimer.Change(0, 1000);
Console.ReadLine();
}
private static void tmrThreadingTimer_TimerCallback(object
state) {
Console.WriteLine("Hello");
throw new Exception("Booom");
}
}
}
Actual result
Hello
Unhandled Exception: System.Exception: Booom
at TestEscape.MainClass.tmrThreadingTimer_TimerCallback (System.Object state)
[0x0000a] in /home/hubert/Projects/TestEscape/TestEscape/Main.cs:25
at System.Threading.Timer+Runner.WaitForDueTime () [0x00070] in
/home/hubert/mono/mcs/class/corlib/System.Threading/Timer.cs:85
at System.Threading.Timer+Runner.Start () [0x00029] in
/home/hubert/mono/mcs/class/corlib/System.Threading/Timer.cs:117
at (wrapper delegate-invoke) System.MulticastDelegate:invoke_void ()
Excepted result :
Hello
Unhandled Exception: System.Exception: Booom
at TestEscape.MainClass.tmrThreadingTimer_TimerCallback (System.Object state)
[0x0000a] in /home/hubert/Projects/TestEscape/TestEscape/Main.cs:25
at System.Threading.Timer+Runner.WaitForDueTime () [0x00070] in
/home/hubert/mono/mcs/class/corlib/System.Threading/Timer.cs:85
at System.Threading.Timer+Runner.Start () [0x00029] in
/home/hubert/mono/mcs/class/corlib/System.Threading/Timer.cs:117
at (wrapper delegate-invoke) System.MulticastDelegate:invoke_void ()
Hello
Unhandled Exception: System.Exception: Booom
at TestEscape.MainClass.tmrThreadingTimer_TimerCallback (System.Object state)
[0x0000a] in /home/hubert/Projects/TestEscape/TestEscape/Main.cs:25
at System.Threading.Timer+Runner.WaitForDueTime () [0x00070] in
/home/hubert/mono/mcs/class/corlib/System.Threading/Timer.cs:85
at System.Threading.Timer+Runner.Start () [0x00029] in
/home/hubert/mono/mcs/class/corlib/System.Threading/Timer.cs:117
at (wrapper delegate-invoke) System.MulticastDelegate:invoke_void ()
Hello
Unhandled Exception: System.Exception: Booom
at TestEscape.MainClass.tmrThreadingTimer_TimerCallback (System.Object state)
[0x0000a] in /home/hubert/Projects/TestEscape/TestEscape/Main.cs:25
at System.Threading.Timer+Runner.WaitForDueTime () [0x00070] in
/home/hubert/mono/mcs/class/corlib/System.Threading/Timer.cs:85
at System.Threading.Timer+Runner.Start () [0x00029] in
/home/hubert/mono/mcs/class/corlib/System.Threading/Timer.cs:117
at (wrapper delegate-invoke) System.MulticastDelegate:invoke_void ()
Hello
Unhandled Exception: System.Exception: Booom
at TestEscape.MainClass.tmrThreadingTimer_TimerCallback (System.Object state)
[0x0000a] in /home/hubert/Projects/TestEscape/TestEscape/Main.cs:25
at System.Threading.Timer+Runner.WaitForDueTime () [0x00070] in
/home/hubert/mono/mcs/class/corlib/System.Threading/Timer.cs:85
at System.Threading.Timer+Runner.Start () [0x00029] in
/home/hubert/mono/mcs/class/corlib/System.Threading/Timer.cs:117
at (wrapper delegate-invoke) System.MulticastDelegate:invoke_void ()
..
I think you should call the callback method in his own thread... instead of
inside the main timer thread...
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list