本文整理汇总了C#中System.Threading.NativeOverlapped类的典型用法代码示例。如果您正苦于以下问题:C# NativeOverlapped类的具体用法?C# NativeOverlapped怎么用?C# NativeOverlapped使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NativeOverlapped类属于System.Threading命名空间,在下文中一共展示了NativeOverlapped类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: SafeNativeOverlapped
public unsafe SafeNativeOverlapped(SafeCloseSocket socketHandle, NativeOverlapped* handle)
: this((IntPtr)handle)
{
SocketHandle = socketHandle;
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"socketHandle:{socketHandle}");
#if DEBUG
SocketHandle.AddRef();
#endif
}
开发者ID:dotnet,项目名称:corefx,代码行数:11,代码来源:SafeNativeOverlapped.cs
示例17: Unpack
unsafe public static Overlapped Unpack (NativeOverlapped *nativeOverlappedPtr)
{
if ((IntPtr) nativeOverlappedPtr == IntPtr.Zero)
throw new ArgumentNullException ("nativeOverlappedPtr");
Overlapped result = new Overlapped ();
result.offsetL = nativeOverlappedPtr->OffsetLow;
result.offsetH = nativeOverlappedPtr->OffsetHigh;
result.evt = (int)nativeOverlappedPtr->EventHandle;
return result;
}
开发者ID:nlhepler,项目名称:mono,代码行数:11,代码来源:Overlapped.cs
示例18: Free
public static unsafe void Free(NativeOverlapped* nativeOverlappedPtr)
{
if (nativeOverlappedPtr == null)
{
throw new ArgumentNullException("nativeOverlappedPtr");
}
Overlapped overlapped = OverlappedData.GetOverlappedFromNative(nativeOverlappedPtr).m_overlapped;
OverlappedData.FreeNativeOverlapped(nativeOverlappedPtr);
OverlappedData overlappedData = overlapped.m_overlappedData;
overlapped.m_overlappedData = null;
OverlappedDataCache.CacheOverlappedData(overlappedData);
}
开发者ID:randomize,项目名称:VimConfig,代码行数:12,代码来源:Overlapped.cs
示例19: MQReceiveMessageByLookupId
public unsafe static int MQReceiveMessageByLookupId(MessageQueueHandle handle, long lookupId, int action, MessagePropertyVariants.MQPROPS properties, NativeOverlapped* overlapped,
SafeNativeMethods.ReceiveCallback receiveCallback, ITransaction transaction)
{
try
{
return IntMQReceiveMessageByLookupId(handle, lookupId, action, properties, overlapped, receiveCallback, transaction);
}
catch (EntryPointNotFoundException)
{
throw new PlatformNotSupportedException(Res.GetString(Res.PlatformNotSupported));
}
}
开发者ID:JianwenSun,项目名称:cc,代码行数:12,代码来源:UnsafeNativeMethods.cs
示例20: Convert
/// <summary>
/// Create a sparse file.
/// </summary>
/// <param name="hFileHandle">Handle of the file to convert to a sparse file.</param>
/// <returns></returns>
public static void Convert(SafeFileHandle hFileHandle)
{
// Use the DeviceIoControl function with the FSCTL_SET_SPARSE control
// code to mark the file as sparse. If you don't mark the file as
// sparse, the FSCTL_SET_ZERO_DATA control code will actually write
// zero bytes to the file instead of marking the region as sparse
// zero area.
int bytesReturned = 0;
var lpOverlapped = new NativeOverlapped();
NativeMethods.DeviceIoControl(hFileHandle,
EIoControlCodes.FsctlSetSparse, IntPtr.Zero, 0, IntPtr.Zero, 0,
ref bytesReturned, ref lpOverlapped);
}
开发者ID:RainsSoft,项目名称:panda,代码行数:18,代码来源:SparseFile.cs
注:本文中的System.Threading.NativeOverlapped类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论