Esempio n. 1
0
        public WindowsApi()
        {
            var fileCompletionInfo = new FILE_COMPLETION_INFORMATION {
                Key = IntPtr.Zero, Port = IntPtr.Zero
            };

            this.fileCompletionInfoPtr = NativeMethods.Allocate(Marshal.SizeOf(fileCompletionInfo));
            Marshal.StructureToPtr(fileCompletionInfo, this.fileCompletionInfoPtr, false);
        }
Esempio n. 2
0
        public async Task StartAsync(
            string pipeName,
            byte[] pipeMessage)
        {
            _pipeName    = pipeName;
            _pipeMessage = pipeMessage;

            if (_fileCompletionInfoPtr == IntPtr.Zero)
            {
                var fileCompletionInfo = new FILE_COMPLETION_INFORMATION()
                {
                    Key = IntPtr.Zero, Port = IntPtr.Zero
                };
                _fileCompletionInfoPtr = Marshal.AllocHGlobal(Marshal.SizeOf(fileCompletionInfo));
                Marshal.StructureToPtr(fileCompletionInfo, _fileCompletionInfoPtr, false);
            }

            await StartAsync().ConfigureAwait(false);

            await Thread.PostAsync(listener => listener.PostCallback(), this).ConfigureAwait(false);
        }
Esempio n. 3
0
        public async Task StartAsync(
            string pipeName,
            ServerAddress address,
            KestrelThread thread)
        {
            _pipeName = pipeName;

            if (_fileCompletionInfoPtr == IntPtr.Zero)
            {
                var fileCompletionInfo = new FILE_COMPLETION_INFORMATION()
                {
                    Key = IntPtr.Zero, Port = IntPtr.Zero
                };
                _fileCompletionInfoPtr = Marshal.AllocHGlobal(Marshal.SizeOf(fileCompletionInfo));
                Marshal.StructureToPtr(fileCompletionInfo, _fileCompletionInfoPtr, false);
            }

            await StartAsync(address, thread).ConfigureAwait(false);

            await Thread.PostAsync(state => ((ListenerPrimary)state).PostCallback(),
                                   this).ConfigureAwait(false);
        }