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

◆ RegisterForCancellation()

unsafe void System.Net.NameResolutionPal.GetAddrInfoExState.RegisterForCancellation ( CancellationToken cancellationToken)
inline

Definition at line 57 of file NameResolutionPal.cs.

58 {
59 if (!cancellationToken.CanBeCanceled)
60 {
61 return;
62 }
63 lock (this)
64 {
65 if (_cancellationContext == null)
66 {
67 return;
68 }
69 _cancellationRegistration = cancellationToken.UnsafeRegister(delegate(object o)
70 {
71 GetAddrInfoExState getAddrInfoExState = (GetAddrInfoExState)o;
72 int num = 0;
73 lock (getAddrInfoExState)
74 {
75 GetAddrInfoExContext* cancellationContext = getAddrInfoExState._cancellationContext;
76 if (cancellationContext != null)
77 {
78 num = global::Interop.Winsock.GetAddrInfoExCancel(&cancellationContext->CancelHandle);
79 }
80 }
81 if (num != 0 && num != 6 && System.Net.NetEventSource.Log.IsEnabled())
82 {
83 System.Net.NetEventSource.Info(getAddrInfoExState, $"GetAddrInfoExCancel returned error {num}", "RegisterForCancellation");
84 }
85 }, this);
86 }
87 }
unsafe GetAddrInfoExContext * _cancellationContext
unsafe GetAddrInfoExState(GetAddrInfoExContext *context, string hostName, bool justAddresses)
CancellationTokenRegistration _cancellationRegistration
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)

References System.Net.NameResolutionPal.GetAddrInfoExState.GetAddrInfoExState(), System.Net.NameResolutionPal.GetAddrInfoExState._cancellationContext, System.Net.NameResolutionPal.GetAddrInfoExState._cancellationRegistration, System.Net.NameResolutionPal.GetAddrInfoExContext.CancelHandle, System.cancellationToken, System.Net.NetEventSource.Info(), and System.Net.NetEventSource.Log.

Referenced by System.Net.NameResolutionPal.GetAddrInfoAsync().