当前位置: 首页>>代码示例>>C#>>正文


C# Threading.NativeOverlapped类代码示例

本文整理汇总了C#中System.Threading.NativeOverlapped的典型用法代码示例。如果您正苦于以下问题:C# NativeOverlapped类的具体用法?C# NativeOverlapped怎么用?C# NativeOverlapped使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NativeOverlapped类属于System.Threading命名空间,在下文中一共展示了NativeOverlapped类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Eject

        public static bool Eject(string driveLetter)
        {
            bool result = false;

            string fileName = string.Format(@"\\.\{0}:", driveLetter);

            IntPtr deviceHandle = _CreateFile(fileName);

            if (deviceHandle != INVALID_HANDLE_VALUE)
            {
                IntPtr null_ptr = IntPtr.Zero;
                int bytesReturned;
                NativeOverlapped overlapped = new NativeOverlapped();

                result = DeviceIoControl(
                    deviceHandle,
                    IOCTL_STORAGE_EJECT_MEDIA,
                    ref null_ptr,
                    0,
                    out null_ptr,
                    0,
                    out bytesReturned,
                    ref overlapped);
                CloseHandle(deviceHandle);
            }
            return result;
        }
开发者ID:kostaslamda,项目名称:win-installer,代码行数:27,代码来源:XenPrepSupport.cs

示例2: HasOverlappedIoCompleted

 internal static bool HasOverlappedIoCompleted(NativeOverlapped lpOverlapped)
 {
     // this method is defined as a MACRO in winbase.h:
     // #define HasOverlappedIoCompleted(lpOverlapped) (((DWORD)(lpOverlapped)->Internal) != STATUS_PENDING)
     // OVERLAPPED::Internal === NativeOverlapped.InternalLow
     return lpOverlapped.InternalLow.ToInt32() != STATUS_PENDING;
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:7,代码来源:NativeMethods.cs

示例3: ReadFile

		public static extern bool ReadFile(
			SafeFileHandle hFile,
			byte* pBuffer,
			int numBytesToRead,
			out int pNumberOfBytesRead,
			NativeOverlapped* lpOverlapped
			);
开发者ID:kijanawoodard,项目名称:ravendb,代码行数:7,代码来源:NativeMethods.cs

示例4: ReadFile

 public static extern bool ReadFile(
   SafeFileHandle hFile,
   IntPtr pBuffer,
   int numberOfBytesToRead,
   int[] pNumberOfBytesRead,
   NativeOverlapped[] lpOverlapped // should be fixed, if not null
   );
开发者ID:mbbill,项目名称:vs-chromium,代码行数:7,代码来源:NativeMethods.cs

示例5: IOCallback

        public unsafe static void IOCallback(uint errorCode, uint numBytes, NativeOverlapped* pOverlapped)
        {
            var state = ThreadPoolBoundHandle.GetNativeOverlappedState(pOverlapped);
            var operation = (ReadOperation)state;

            operation.ThreadPoolBoundHandle.FreeNativeOverlapped(operation.Overlapped);

            operation.Offset += (int)numBytes;

            var buffer = operation.BoxedBuffer.Value;

            buffer.Advance((int)numBytes);
            var task = buffer.FlushAsync();

            if (numBytes == 0 || operation.Writer.Writing.IsCompleted)
            {
                operation.Writer.Complete();

                // The operation can be disposed when there's nothing more to produce
                operation.Dispose();
            }
            else if (task.IsCompleted)
            {
                operation.Read();
            }
            else
            {
                // Keep reading once we get the completion
                task.ContinueWith((t, s) => ((ReadOperation)s).Read(), operation);
            }
        }
开发者ID:AlexGhiondea,项目名称:corefxlab,代码行数:31,代码来源:FileReader.cs

示例6: Update

        public static unsafe void Update(int index, int[] analogData, byte[] digitalData)
        {
            //Create the structure
              var state = new JoystickState();
              state.Signature = (uint)0x53544143;
              state.NumAnalog = (char)63;
              state.NumDigital = (char)128;
              state.Analog = new int[state.NumAnalog];
              state.Digital = new char[state.NumDigital];

              //Fill it with our data
              if (analogData != null)
            Array.Copy(analogData, 0, state.Analog, 0, Math.Min(analogData.Length, state.Analog.Length));
              if (digitalData != null)
            Array.Copy(digitalData, 0, state.Digital, 0, Math.Min(digitalData.Length, state.Digital.Length));

              //Send the data
              uint bytesReturned = 0;
              NativeOverlapped overlapped = new NativeOverlapped();
              var h = _GetHandle(index);
              bool ret = DeviceIoControl(h, 0x00220000,
             state, (uint)Marshal.SizeOf(state),
             IntPtr.Zero, 0, ref bytesReturned, ref overlapped);

              if (!ret)
              {
            //TODO: Do something with this?
            int lastError = Marshal.GetLastWin32Error();

            //Invalidate the handle
            _CloseHandle(h);
            _handles[index] = null;
              }
        }
开发者ID:aromis,项目名称:uDrawTablet,代码行数:34,代码来源:PPJoyInterface.cs

示例7: AsyncPSCallback

 private static unsafe void AsyncPSCallback(uint errorCode, uint numBytes, NativeOverlapped* pOverlapped)
 {
     PipeStreamAsyncResult asyncResult = (PipeStreamAsyncResult) Overlapped.Unpack(pOverlapped).AsyncResult;
     asyncResult._numBytes = (int) numBytes;
     if (!asyncResult._isWrite && (((errorCode == 0x6d) || (errorCode == 0xe9)) || (errorCode == 0xe8)))
     {
         errorCode = 0;
         numBytes = 0;
     }
     if (errorCode == 0xea)
     {
         errorCode = 0;
         asyncResult._isMessageComplete = false;
     }
     else
     {
         asyncResult._isMessageComplete = true;
     }
     asyncResult._errorCode = (int) errorCode;
     asyncResult._completedSynchronously = false;
     asyncResult._isComplete = true;
     ManualResetEvent event2 = asyncResult._waitHandle;
     if ((event2 != null) && !event2.Set())
     {
         System.IO.__Error.WinIOError();
     }
     AsyncCallback callback = asyncResult._userCallback;
     if (callback != null)
     {
         callback(asyncResult);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:32,代码来源:PipeStream.cs

示例8: Free

		unsafe public static void Free (NativeOverlapped *nativeOverlappedPtr)
		{
			if ((IntPtr) nativeOverlappedPtr == IntPtr.Zero)
				throw new ArgumentNullException ("nativeOverlappedPtr");

			Marshal.FreeHGlobal ((IntPtr) nativeOverlappedPtr);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:Overlapped.cs

示例9: Unpack

 public static unsafe Overlapped Unpack(NativeOverlapped* nativeOverlappedPtr)
 {
     if (nativeOverlappedPtr == null)
     {
         throw new ArgumentNullException("nativeOverlappedPtr");
     }
     return OverlappedData.GetOverlappedFromNative(nativeOverlappedPtr).m_overlapped;
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:8,代码来源:Overlapped.cs

示例10: HidDevice

    public HidDevice(string devicePath)
    {
      _devicePath = devicePath;

      _overlapped = new NativeOverlapped();
      _overlapped.EventHandle = NativeInterface.CreateEvent(IntPtr.Zero, false, false, null);
      _pinnedOverlapped = GCHandle.Alloc(_overlapped, GCHandleType.Pinned);
    }
开发者ID:brandonlw,项目名称:vicar,代码行数:8,代码来源:HidDevice.cs

示例11: Eject

 /// <summary>
 /// 
 /// </summary>
 /// <param name="drive"></param>
 public static void Eject(String drive)
 {
     using (SafeFileHandle hDevice = Win32.CreateFile(String.Format(@"\\.\{0}:", drive), FileAccess.Read, FileShare.Read, IntPtr.Zero, FileMode.Open, Win32.EFileAttributes.Normal, IntPtr.Zero))
     {
         UInt32 retVal = 0;
         NativeOverlapped retOverlapped = new NativeOverlapped();
         Win32.DeviceIoControl(hDevice, Win32.EIOControlCode.StorageEjectMedia, null, 0, null, 0, ref retVal, ref retOverlapped);
     }
 }
开发者ID:mayuki,项目名称:AppleWirelessKeyboardHelper,代码行数:13,代码来源:Util.cs

示例12: Callback

            private void Callback(uint errorCode, uint numBytes, NativeOverlapped* pNOlap)
            {
                // Execute the task
                _scheduler.TryExecuteTask(Task);

                // Put this item back into the pool for someone else to use
                var pool = _scheduler._availableWorkItems;
                if(pool != null) pool.Add(this);
                else Overlapped.Free(pNOlap);
            }
开发者ID:reuzel,项目名称:CqlSharp,代码行数:10,代码来源:IOTaskScheduler.cs

示例13: SafeNativeOverlapped

        public unsafe SafeNativeOverlapped(SafeCloseSocket socketHandle, NativeOverlapped* handle)
            : this((IntPtr)handle)
        {
            _safeCloseSocket = socketHandle;

            GlobalLog.Print("SafeNativeOverlapped#" + Logging.HashString(this) + "::ctor(socket#" + Logging.HashString(socketHandle) + ")");
#if DEBUG
            _safeCloseSocket.AddRef();
#endif
        }
开发者ID:natemcmaster,项目名称:corefx,代码行数:10,代码来源:SafeNativeOverlapped.cs

示例14: SharedLockFile

      public virtual int SharedLockFile( sqlite3_file pFile, long offset, long length )
      {
        Debug.Assert( length == SHARED_SIZE );
        Debug.Assert( offset == SHARED_FIRST );
        System.Threading.NativeOverlapped ovlp = new System.Threading.NativeOverlapped();
        ovlp.OffsetLow = (int)offset;
        ovlp.OffsetHigh = 0;
        ovlp.EventHandle = IntPtr.Zero;

        return LockFileEx( pFile.fs.Handle, LOCKFILE_FAIL_IMMEDIATELY, 0, (uint)length, 0, ref ovlp ) ? 1 : 0;
      }
开发者ID:plainprogrammer,项目名称:csharp-sqlite,代码行数:11,代码来源:os_win_c.cs

示例15: AsyncFSCallback

 private static unsafe void AsyncFSCallback(uint errorCode, uint numBytes, NativeOverlapped* pOverlapped)
 {
     PipeAsyncResult asyncResult = (PipeAsyncResult) Overlapped.Unpack(pOverlapped).AsyncResult;
     asyncResult._numBytes = (int) numBytes;
     if (errorCode == 0x6dL)
     {
         errorCode = 0;
     }
     asyncResult._errorCode = (int) errorCode;
     asyncResult._userCallback(asyncResult);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:IpcPort.cs


注:本文中的System.Threading.NativeOverlapped类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。