1
- using System . Threading ;
2
- using System . Threading . Tasks ;
1
+ using System . Threading . Tasks ;
3
2
using Microsoft . Samples . Debugging . CorDebug ;
4
3
using Microsoft . Samples . Debugging . CorDebug . NativeApi ;
4
+ using Mono . Debugging . Client ;
5
5
using Mono . Debugging . Evaluation ;
6
6
7
7
namespace Mono . Debugging . Win32
@@ -40,10 +40,12 @@ void DoProcessEvalFinished (CorEvalEventArgs evalArgs, bool isException)
40
40
return ;
41
41
context . Session . OnEndEvaluating ( ) ;
42
42
evalArgs . Continue = false ;
43
- if ( aborted ) {
43
+ if ( Token . IsCancellationRequested ) {
44
+ DebuggerLoggingService . LogMessage ( "EvalFinished() but evaluation was cancelled" ) ;
44
45
tcs . TrySetCanceled ( ) ;
45
46
}
46
47
else {
48
+ DebuggerLoggingService . LogMessage ( "EvalFinished(). Setting the result" ) ;
47
49
tcs . TrySetResult ( new OperationResult < CorValue > ( evalArgs . Eval . Result , isException ) ) ;
48
50
}
49
51
}
@@ -66,30 +68,16 @@ public override string Description
66
68
{
67
69
var met = function . GetMethodInfo ( context . Session ) ;
68
70
if ( met == null )
69
- return "< Unknown> " ;
71
+ return "[ Unknown method] " ;
70
72
if ( met . DeclaringType == null )
71
73
return met . Name ;
72
74
return met . DeclaringType . FullName + "." + met . Name ;
73
75
}
74
76
}
75
77
76
78
readonly TaskCompletionSource < OperationResult < CorValue > > tcs = new TaskCompletionSource < OperationResult < CorValue > > ( ) ;
77
- bool aborted = false ;
78
- const int DelayAfterAbort = 500 ;
79
79
80
- protected override void AfterCancelledImpl ( int elapsedAfterCancelMs )
81
- {
82
- if ( tcs . TrySetCanceled ( ) ) {
83
- // really cancelled for the first time not before. so we should check that we awaited necessary amout of time after Abort() call
84
- // else if we return too earle after Abort() the process may be PROCESS_NOT_SYNCHRONIZED
85
- if ( elapsedAfterCancelMs < DelayAfterAbort ) {
86
- Thread . Sleep ( DelayAfterAbort - elapsedAfterCancelMs ) ;
87
- }
88
- }
89
- context . Session . OnEndEvaluating ( ) ;
90
- }
91
-
92
- protected override Task < OperationResult < CorValue > > InvokeAsyncImpl ( CancellationToken token )
80
+ protected override Task < OperationResult < CorValue > > InvokeAsyncImpl ( )
93
81
{
94
82
SubscribeOnEvals ( ) ;
95
83
@@ -102,19 +90,24 @@ protected override Task<OperationResult<CorValue>> InvokeAsyncImpl (Cancellation
102
90
context . Session . OnStartEvaluating ( ) ;
103
91
context . Session . Process . Continue ( false ) ;
104
92
Task = tcs . Task ;
105
- // Don't pass token here, because it causes immediately task cancellation which must be performed by debugger event or real timeout
106
- // ReSharper disable once MethodSupportsCancellation
93
+ // Don't pass token here, because it causes immediately task cancellation which must be performed by debugger event or real timeout
107
94
return Task . ContinueWith ( task => {
108
95
UnSubcribeOnEvals ( ) ;
109
96
return task . Result ;
110
97
} ) ;
111
98
}
112
99
113
100
114
- protected override void CancelImpl ( )
101
+ protected override void AbortImpl ( int abortCallTimes )
115
102
{
116
- eval . Abort ( ) ;
117
- aborted = true ;
103
+ if ( abortCallTimes < 10 ) {
104
+ DebuggerLoggingService . LogMessage ( "Calling Abort()" ) ;
105
+ eval . Abort ( ) ;
106
+ }
107
+ else {
108
+ DebuggerLoggingService . LogMessage ( "Calling RudeAbort()" ) ;
109
+ eval . RudeAbort ( ) ;
110
+ }
118
111
}
119
112
}
120
113
}
0 commit comments