Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Complete() [3/3]

virtual void System.Net.LazyAsyncResult.Complete ( IntPtr userToken)
inlineprotectedvirtualinherited

Reimplemented in System.Net.ContextAwareResult, and System.Net.ContextAwareResult.

Definition at line 182 of file LazyAsyncResult.cs.

183 {
184 bool flag = false;
185 ThreadContext currentThreadContext = CurrentThreadContext;
186 try
187 {
188 currentThreadContext._nestedIOCount++;
189 if (_asyncCallback != null)
190 {
191 if (System.Net.NetEventSource.Log.IsEnabled())
192 {
193 System.Net.NetEventSource.Info(this, "Invoking callback", "Complete");
194 }
195 if (currentThreadContext._nestedIOCount >= 50)
196 {
197 if (System.Net.NetEventSource.Log.IsEnabled())
198 {
199 System.Net.NetEventSource.Info(this, "*** OFFLOADED the user callback ****", "Complete");
200 }
201 Task.Factory.StartNew(delegate(object s)
202 {
205 flag = true;
206 }
207 else
208 {
209 _asyncCallback(this);
210 }
211 }
212 else if (System.Net.NetEventSource.Log.IsEnabled())
213 {
214 System.Net.NetEventSource.Info(this, "No callback to invoke", "Complete");
215 }
216 }
217 finally
218 {
219 currentThreadContext._nestedIOCount--;
220 if (!flag)
221 {
222 Cleanup();
223 }
224 }
225 }
static ThreadContext CurrentThreadContext
static void WorkerThreadComplete(object state)
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
static new TaskFactory< TResult > Factory
Definition Task.cs:56

References System.Net.LazyAsyncResult._asyncCallback, System.Net.LazyAsyncResult.Cleanup(), System.Net.LazyAsyncResult.CurrentThreadContext, System.Threading.Tasks.TaskScheduler.Default, System.Threading.Tasks.Task< TResult >.Factory, System.Net.NetEventSource.Info(), System.Net.NetEventSource.Log, System.Threading.CancellationToken.None, System.s, and System.Net.LazyAsyncResult.WorkerThreadComplete().