summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Threading/Overlapped.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Threading/Overlapped.cs')
-rw-r--r--src/mscorlib/src/System/Threading/Overlapped.cs54
1 files changed, 21 insertions, 33 deletions
diff --git a/src/mscorlib/src/System/Threading/Overlapped.cs b/src/mscorlib/src/System/Threading/Overlapped.cs
index 2b192c7b3a..d3caff5e74 100644
--- a/src/mscorlib/src/System/Threading/Overlapped.cs
+++ b/src/mscorlib/src/System/Threading/Overlapped.cs
@@ -31,7 +31,6 @@ namespace System.Threading
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
- using System.Security.Permissions;
using System.Runtime.ConstrainedExecution;
using System.Diagnostics;
using System.Diagnostics.Contracts;
@@ -44,7 +43,6 @@ namespace System.Threading
// The first five matches OVERLAPPED structure.
// The remaining are reserved at the end
[System.Runtime.InteropServices.StructLayout(LayoutKind.Sequential)]
- [System.Runtime.InteropServices.ComVisible(true)]
public struct NativeOverlapped
{
public IntPtr InternalLow;
@@ -71,13 +69,11 @@ namespace System.Threading
{
}
- internal _IOCompletionCallback(IOCompletionCallback ioCompletionCallback, ref StackCrawlMark stackMark)
+ internal _IOCompletionCallback(IOCompletionCallback ioCompletionCallback)
{
_ioCompletionCallback = ioCompletionCallback;
// clone the exection context
- _executionContext = ExecutionContext.Capture(
- ref stackMark,
- ExecutionContext.CaptureOptions.IgnoreSyncCtx | ExecutionContext.CaptureOptions.OptimizeDefaultCase);
+ _executionContext = ExecutionContext.Capture();
}
// Context callback: same sig for SendOrPostCallback and ContextCallback
static internal ContextCallback _ccb = new ContextCallback(IOCompletionCallback_Context);
@@ -103,26 +99,23 @@ namespace System.Threading
overlapped = OverlappedData.GetOverlappedFromNative(pOVERLAP).m_overlapped;
helper = overlapped.iocbHelper;
- if (helper == null || helper._executionContext == null || helper._executionContext.IsDefaultFTContext(true))
- {
- // We got here because of UnsafePack (or) Pack with EC flow supressed
- IOCompletionCallback callback = overlapped.UserCallback;
- callback( errorCode, numBytes, pOVERLAP);
- }
- else
- {
- // We got here because of Pack
- helper._errorCode = errorCode;
- helper._numBytes = numBytes;
- helper._pOVERLAP = pOVERLAP;
- using (ExecutionContext executionContext = helper._executionContext.CreateCopy())
- ExecutionContext.Run(executionContext, _ccb, helper, true);
- }
-
- //Quickly check the VM again, to see if a packet has arrived.
-
+ if (helper == null || helper._executionContext == null || helper._executionContext == ExecutionContext.Default)
+ {
+ // We got here because of UnsafePack (or) Pack with EC flow supressed
+ IOCompletionCallback callback = overlapped.UserCallback;
+ callback( errorCode, numBytes, pOVERLAP);
+ }
+ else
+ {
+ // We got here because of Pack
+ helper._errorCode = errorCode;
+ helper._numBytes = numBytes;
+ helper._pOVERLAP = pOVERLAP;
+ ExecutionContext.Run(helper._executionContext, _ccb, helper);
+ }
+
+ //Quickly check the VM again, to see if a packet has arrived.
OverlappedData.CheckVMForIOPacket(out pOVERLAP, out errorCode, out numBytes);
-
} while (pOVERLAP != null);
}
@@ -174,17 +167,15 @@ namespace System.Threading
m_nativeOverlapped.InternalHigh = (IntPtr)0;
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
unsafe internal NativeOverlapped* Pack(IOCompletionCallback iocb, Object userData)
{
if (!m_pinSelf.IsNull()) {
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_Overlapped_Pack"));
}
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
if (iocb != null)
{
- m_iocbHelper = new _IOCompletionCallback(iocb, ref stackMark);
+ m_iocbHelper = new _IOCompletionCallback(iocb);
m_iocb = iocb;
}
else
@@ -229,7 +220,6 @@ namespace System.Threading
return AllocateNativeOverlapped();
}
- [ComVisible(false)]
internal IntPtr UserHandle
{
get { return m_nativeOverlapped.EventHandle; }
@@ -255,7 +245,6 @@ namespace System.Threading
#region class Overlapped
/// <internalonly/>
- [System.Runtime.InteropServices.ComVisible(true)]
public class Overlapped
{
private OverlappedData m_overlappedData;
@@ -307,7 +296,6 @@ namespace System.Threading
set { m_overlappedData.UserHandle = new IntPtr(value); }
}
- [ComVisible(false)]
public IntPtr EventHandleIntPtr
{
get { return m_overlappedData.UserHandle; }
@@ -336,7 +324,7 @@ namespace System.Threading
return Pack (iocb, null);
}
- [CLSCompliant(false),ComVisible(false)]
+ [CLSCompliant(false)]
unsafe public NativeOverlapped* Pack(IOCompletionCallback iocb, Object userData)
{
return m_overlappedData.Pack(iocb, userData);
@@ -349,7 +337,7 @@ namespace System.Threading
return UnsafePack (iocb, null);
}
- [CLSCompliant(false), ComVisible(false)]
+ [CLSCompliant(false)]
unsafe public NativeOverlapped* UnsafePack(IOCompletionCallback iocb, Object userData)
{
return m_overlappedData.UnsafePack(iocb, userData);