1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using System.Threading;
7
namespace Debugger.Tests
9
public class ControlFlow_MainThreadExit
11
static ManualResetEvent doSomething = new ManualResetEvent(false);
13
public static void Main()
15
System.Threading.Thread t = new System.Threading.Thread(WaitForALongTime);
16
t.Name = "Worker thread";
18
// Wait for the thread to start
19
System.Threading.Thread.Sleep(500);
20
System.Diagnostics.Debugger.Break();
23
static void WaitForALongTime()
25
doSomething.WaitOne();
31
namespace Debugger.Tests {
32
public partial class DebuggerTests
34
[NUnit.Framework.Test]
35
public void ControlFlow_MainThreadExit()
38
ObjectDump("ThreadsBeforeExit", process.Threads);
39
process.AsyncContinue();
40
// Wait for the main thread to exit
41
System.Threading.Thread.Sleep(500);
43
ObjectDump("ThreadsAfterExit", process.Threads);
52
<?xml version="1.0" encoding="utf-8"?>
55
name="ControlFlow_MainThreadExit.cs">
57
<ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded>
58
<ModuleLoaded>ControlFlow_MainThreadExit.exe (Has symbols)</ModuleLoaded>
59
<DebuggingPaused>Break ControlFlow_MainThreadExit.cs:20,4-20,40</DebuggingPaused>
62
Selected="Thread Name = Suspended = False">
65
Callstack="{static void Debugger.Tests.ControlFlow_MainThreadExit.Main()}"
66
CurrentExceptionType="0"
69
MostRecentStackFrame="static void Debugger.Tests.ControlFlow_MainThreadExit.Main()"
72
RuntimeValue="{System.Threading.Thread}"
73
SelectedStackFrame="static void Debugger.Tests.ControlFlow_MainThreadExit.Main()" />
77
Callstack="{static Boolean System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext), Boolean System.Threading.WaitHandle.WaitOne(Int32 millisecondsTimeout, Boolean exitContext), Boolean System.Threading.WaitHandle.WaitOne(), static void Debugger.Tests.ControlFlow_MainThreadExit.WaitForALongTime(), static void System.Threading.ThreadHelper.ThreadStart_Context(Object state), static void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx), static void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state), void System.Threading.ThreadHelper.ThreadStart()}"
78
CurrentExceptionType="0"
81
MostRecentStackFrame="static Boolean System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)"
84
RuntimeValue="{System.Threading.Thread}" />
87
<DebuggingPaused>ForcedBreak ControlFlow_MainThreadExit.cs:25,4-25,26</DebuggingPaused>
90
Selected="Thread Name = Worker thread Suspended = False">
93
CurrentExceptionType="0"
96
RuntimeValue="{Exception: The state of the thread is invalid. (Exception from HRESULT: 0x8013132D)}" />
100
Callstack="{static Boolean System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext), Boolean System.Threading.WaitHandle.WaitOne(Int32 millisecondsTimeout, Boolean exitContext), Boolean System.Threading.WaitHandle.WaitOne(), static void Debugger.Tests.ControlFlow_MainThreadExit.WaitForALongTime(), static void System.Threading.ThreadHelper.ThreadStart_Context(Object state), static void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx), static void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state), void System.Threading.ThreadHelper.ThreadStart()}"
101
CurrentExceptionType="0"
103
IsInValidState="True"
104
MostRecentStackFrame="static Boolean System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)"
107
RuntimeValue="{System.Threading.Thread}"
108
SelectedStackFrame="static void Debugger.Tests.ControlFlow_MainThreadExit.WaitForALongTime()" />
114
#endif // EXPECTED_OUTPUT