unsafe static void Main(string[] args) { IntPtr fileHandle = CreateFile("failas.txt", (uint)FileAccess.FileReadWrite, 0, IntPtr.Zero, 1, 0x40000000, IntPtr.Zero); if (fileHandle == IntPtr.Zero) { throw new Win32Exception(); } Console.WriteLine(fileHandle.ToInt32()); Console.ReadKey(); overlap lapped = new overlap(); ManualResetEvent evente = new ManualResetEvent(false); lapped.EventHandle = evente.SafeWaitHandle.DangerousGetHandle(); //Console.WriteLine(lapped.EventHandle.ToInt32() + '\n'); IOCompletionPort.IOCompletionPort comPort = new IOCompletionPort.IOCompletionPort(fileHandle, 3, 4); ThreadStart action = () => { Console.WriteLine(comPort.Handle.ToInt32()); IOStatus iOStatus = comPort.GetPacket(0); Console.WriteLine(iOStatus.lpCompletionKey + " " + iOStatus.lpNumberOfBytes + " " + iOStatus.EventHandle + '\n'); }; new Thread(action).Start(); byte[] buffer = new byte[] { 34, 2, 100, 200, 45 }; uint numberWritten = 0; IOCompletionPort.IOCompletionPort.WriteFile(fileHandle, buffer, 5, out numberWritten, lapped); Console.WriteLine(numberWritten + '\n'); Console.ReadKey(); }
unsafe static void IOcomp(IntPtr intance, IntPtr context, overlap overlapped, ulong iorezults, UIntPtr bytesTransfared, IntPtr PTP) { }