ToIntPtr() public method

public ToIntPtr ( ) : IntPtr
return System.IntPtr
Beispiel #1
0
        private Task <bool> InternalSendRequestAsync(WinHttpRequestState state)
        {
            state.TcsSendRequest = new TaskCompletionSource <bool>(TaskCreationOptions.RunContinuationsAsynchronously);

            lock (state.Lock)
            {
                if (!Interop.WinHttp.WinHttpSendRequest(
                        state.RequestHandle,
                        null,
                        0,
                        IntPtr.Zero,
                        0,
                        0,
                        state.ToIntPtr()))
                {
                    WinHttpException.ThrowExceptionUsingLastError();
                }
            }

            return(state.TcsSendRequest.Task);
        }
Beispiel #2
0
        private Task<bool> InternalSendRequestAsync(WinHttpRequestState state)
        {
            state.TcsSendRequest = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);

            lock (state.Lock)
            {
                if (!Interop.WinHttp.WinHttpSendRequest(
                    state.RequestHandle,
                    null,
                    0,
                    IntPtr.Zero,
                    0,
                    0,
                    state.ToIntPtr()))
                {
                    WinHttpException.ThrowExceptionUsingLastError();
                }
            }

            return state.TcsSendRequest.Task;
        }
Beispiel #3
0
        private RendezvousAwaitable<int> InternalSendRequestAsync(WinHttpRequestState state)
        {
            lock (state.Lock)
            {
                state.Pin();
                if (!Interop.WinHttp.WinHttpSendRequest(
                    state.RequestHandle,
                    null,
                    0,
                    IntPtr.Zero,
                    0,
                    0,
                    state.ToIntPtr()))
                {
                    // Dispose (which will unpin) the state object. Since this failed, WinHTTP won't associate
                    // our context value (state object) to the request handle. And thus we won't get HANDLE_CLOSING
                    // notifications which would normally cause the state object to be unpinned and disposed.
                    state.Dispose();
                    WinHttpException.ThrowExceptionUsingLastError();
                }
            }

            return state.LifecycleAwaitable;
        }
Beispiel #4
0
        private Task<bool> InternalSendRequestAsync(WinHttpRequestState state)
        {
            state.TcsSendRequest = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);

            lock (state.Lock)
            {
                state.Pin();
                if (!Interop.WinHttp.WinHttpSendRequest(
                    state.RequestHandle,
                    null,
                    0,
                    IntPtr.Zero,
                    0,
                    0,
                    state.ToIntPtr()))
                {
                    // Dispose (which will unpin) the state object. Since this failed, WinHTTP won't associate
                    // our context value (state object) to the request handle. And thus we won't get HANDLE_CLOSING
                    // notifications which would normally cause the state object to be unpinned and disposed.
                    state.Dispose();
                    WinHttpException.ThrowExceptionUsingLastError();
                }
            }

            return state.TcsSendRequest.Task;
        }