本文整理汇总了C#中LibuvSharp.Loop类的典型用法代码示例。如果您正苦于以下问题:C# Loop类的具体用法?C# Loop怎么用?C# Loop使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Loop类属于LibuvSharp命名空间,在下文中一共展示了Loop类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Connect
public static void Connect(Loop loop, IPAddress ipAddress, int port, Action<Exception, Tcp> callback)
{
Ensure.ArgumentNotNull(loop, "loop");
Ensure.ArgumentNotNull(ipAddress, "ipAddress");
Ensure.ArgumentNotNull(callback, "callback");
ConnectRequest cpr = new ConnectRequest();
Tcp socket = new Tcp(loop);
cpr.Callback = (status, cpr2) => {
if (status == 0) {
callback(null, socket);
} else {
socket.Close();
callback(Ensure.Success(loop), null);
}
};
int r;
if (ipAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) {
r = uv_tcp_connect(cpr.Handle, socket.handle, UV.uv_ip4_addr(ipAddress.ToString(), port), CallbackPermaRequest.StaticEnd);
} else {
r = uv_tcp_connect6(cpr.Handle, socket.handle, UV.uv_ip6_addr(ipAddress.ToString(), port), CallbackPermaRequest.StaticEnd);
}
Ensure.Success(r, loop);
}
示例2: Chown
public static void Chown(Loop loop, string path, int uid, int gid, Action<Exception> callback)
{
var fsr = new FileSystemRequest();
fsr.Callback = (ex, fsr2) => { callback(ex); };
int r = uv_fs_chown(loop.Handle, fsr.Handle, path, uid, gid, FileSystemRequest.StaticEnd);
Ensure.Success(r, loop);
}
示例3: TTY
public TTY(Loop loop, int fd, bool readable)
: base(loop, HandleType.UV_TTY)
{
FileDescriptor = fd;
int r = uv_tty_init(loop.NativeHandle, NativeHandle, fd, (readable ? 1 : 0));
Ensure.Success(r, Loop);
}
示例4: Create
public static void Create(Loop loop, string path, int mode, Action<Exception> callback)
{
var fsr = new FileSystemRequest();
fsr.Callback = callback;
int r = uv_fs_mkdir(loop.NativeHandle, fsr.Handle, path, mode, FileSystemRequest.CallbackDelegate);
Ensure.Success(r);
}
示例5: Every
public static UVTimer Every(Loop loop, TimeSpan repeat, Action callback)
{
var timer = new UVTimer(loop);
timer.Tick += callback;
timer.Start(repeat, repeat);
return timer;
}
示例6: TTY
public TTY(Loop loop, IntPtr fd, bool readable)
: base(loop, UvHandleType.UV_TTY)
{
FileDescriptor = fd;
int r = uv_tty_init(loop.Handle, handle, fd, (readable ? 1 : 0));
Ensure.Success(r, Loop);
}
示例7: Close
public void Close(Loop loop, Action<Exception> callback)
{
var fsr = new FileSystemRequest();
fsr.Callback = callback;
int r = uv_fs_close(loop.NativeHandle, fsr.Handle, FileDescriptor, FileSystemRequest.CallbackDelegate);
Ensure.Success(r);
}
示例8: UVStream
internal UVStream(Loop loop, IntPtr handle)
: base(loop, handle)
{
read_cb_unix = read_callback_u;
read_cb_win = read_callback_w;
stream = (uv_stream_t *)(handle.ToInt64() + Handle.Size(HandleType.UV_HANDLE));
}
示例9: Delete
public static void Delete(Loop loop, string path, Action<Exception> callback)
{
var fsr = new FileSystemRequest();
fsr.Callback = callback;
int r = uv_fs_rmdir(loop.NativeHandle, fsr.Handle, path, FileSystemRequest.StaticEnd);
Ensure.Success(r, loop);
}
示例10: Chown
public static void Chown(Loop loop, string path, int uid, int gid, Action<Exception> callback)
{
var fsr = new FileSystemRequest();
fsr.Callback = callback;
int r = uv_fs_chown(loop.NativeHandle, fsr.Handle, path, uid, gid, FileSystemRequest.CallbackDelegate);
Ensure.Success(r);
}
示例11: FileSystemWatcher
public FileSystemWatcher(Loop loop, string path, FileSystemEventFlags flags)
: base(loop, HandleType.UV_FS_EVENT)
{
uv_fs_event = fs_event;
int r = uv_fs_event_init(loop.NativeHandle, NativeHandle, path, uv_fs_event, (int)flags);
Ensure.Success(r, loop);
}
示例12: Rename
public static void Rename(Loop loop, string path, string newPath, Action<Exception> callback)
{
var fsr = new FileSystemRequest();
fsr.Callback = callback;
int r = uv_fs_rename(loop.NativeHandle, fsr.Handle, path, newPath, fsr.End);
Ensure.Success(r);
}
示例13: FileSystemEvent
public FileSystemEvent(Loop loop, string path)
: base(loop, UvHandleType.UV_FS_EVENT)
{
uv_fs_event = fs_event;
int r = uv_fs_event_init(loop.Handle, handle, path, uv_fs_event, 0);
Ensure.Success(r, loop);
}
示例14: SignalWatcher
public SignalWatcher(Loop loop, Signum signum, Action callback)
: this(loop, new Signum[] { signum }, (num) => {
if (callback != null) {
callback();
}
})
{
}
示例15: Poll
public Poll(Loop loop, int fd)
: base(loop, UvHandleType.UV_POLL)
{
int r = uv_poll_init(loop.Handle, handle, fd);
Ensure.Success(r, Loop);
poll_cb += pollcallback;
}