private static unsafe void AsyncCb(IntPtr ptrUvAsyncHandle) { AsyncHandle asyncHandlea = (AsyncHandle)GCHandle.FromIntPtr(*(IntPtr *)((void *)ptrUvAsyncHandle)).Target; if (asyncHandlea == null) { return; } try { asyncHandlea._callback(); } catch { //ignore } }
public void AsyncInit(LoopHandle loopHandle, AsyncHandle a, AsyncInit_callback asyncInitCallback) { CheckError(_uv_async_init(loopHandle, a, asyncInitCallback)); }
/// <summary> /// uv_async_send(线程通信),消息的发送是异步的,在另外一个线程中多次(二次或更多)调用了uv_async_send函数后它只会保证uv_async_init回调函数至少被调用一次 ///uv_async_send是非阻塞的,同样也不是线程安全的,在变量访问时应该尽量和互斥量或读写锁来保证访问顺序 /// </summary> /// <param name="asyncHandle"></param> public void AsyncSend(AsyncHandle asyncHandle) { CheckError(_uv_async_send(asyncHandle)); }