本文整理汇总了C#中LibuvSharp.Loop类的典型用法代码示例。如果您正苦于以下问题:C# Loop类的具体用法?C# Loop怎么用?C# Loop使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Loop类属于LibuvSharp命名空间,在下文中一共展示了Loop类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:carlokok,项目名称:LibuvSharp,代码行数:26,代码来源:Tcp.cs
示例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);
}
开发者ID:carlokok,项目名称:LibuvSharp,代码行数:7,代码来源:UVFile.cs
示例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);
}
开发者ID:GamingAtheist,项目名称:LibuvSharp,代码行数:7,代码来源:TTY.cs
示例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);
}
开发者ID:lrdcasimir,项目名称:LibuvSharp,代码行数:7,代码来源:UVDirectory.cs
示例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;
}
开发者ID:txdv,项目名称:LibuvSharp,代码行数:7,代码来源:UVTimer.cs
示例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);
}
开发者ID:carlokok,项目名称:LibuvSharp,代码行数:7,代码来源:TTY.cs
示例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);
}
开发者ID:lrdcasimir,项目名称:LibuvSharp,代码行数:7,代码来源:UVFile.cs
示例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));
}
开发者ID:GamingAtheist,项目名称:LibuvSharp,代码行数:7,代码来源:UVStream.cs
示例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);
}
开发者ID:oskarwkarlsson,项目名称:LibuvSharp,代码行数:7,代码来源:UVDirectory.cs
示例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);
}
开发者ID:yuzd,项目名称:LibuvSharp,代码行数:7,代码来源:UVFile.cs
示例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);
}
开发者ID:GamingAtheist,项目名称:LibuvSharp,代码行数:7,代码来源:FileSystemWatcher.cs
示例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);
}
开发者ID:lrdcasimir,项目名称:LibuvSharp,代码行数:7,代码来源:UVDirectory.cs
示例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);
}
开发者ID:carlokok,项目名称:LibuvSharp,代码行数:7,代码来源:FileSystemEvent.cs
示例14: SignalWatcher
public SignalWatcher(Loop loop, Signum signum, Action callback)
: this(loop, new Signum[] { signum }, (num) => {
if (callback != null) {
callback();
}
})
{
}
开发者ID:txdv,项目名称:LibuvSharp.Terminal,代码行数:8,代码来源:SignalWatcher.cs
示例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;
}
开发者ID:carlokok,项目名称:LibuvSharp,代码行数:8,代码来源:Poll.cs
示例16: Success
internal static void Success(int errorCode, Loop loop)
{
if (errorCode < 0) {
var ex = Success(loop);
if (ex != null) {
throw ex;
}
}
}
开发者ID:oskarwkarlsson,项目名称:LibuvSharp,代码行数:9,代码来源:Ensure.cs
示例17: Handle
internal Handle(Loop loop, IntPtr handle)
{
Ensure.ArgumentNotNull(loop, "loop");
this.handle = handle;
GCHandle = GCHandle.Alloc(this);
Loop = loop;
Loop.handles[handle] = this;
}
开发者ID:carlokok,项目名称:LibuvSharp,代码行数:10,代码来源:Handle.cs
示例18: Delete
public static void Delete(Loop loop, string path, Action<Exception> callback)
{
var fsr = new FileSystemRequest();
fsr.Callback = (ex, fsr2) => {
if (callback != null) {
callback(ex);
};
};
int r = uv_fs_rmdir(loop.Handle, fsr.Handle, path, FileSystemRequest.StaticEnd);
Ensure.Success(r, loop);
}
开发者ID:carlokok,项目名称:LibuvSharp,代码行数:11,代码来源:UVDirectory.cs
示例19: Udp
public Udp(Loop loop)
: base(loop, HandleType.UV_UDP)
{
int r = uv_udp_init(loop.NativeHandle, NativeHandle);
Ensure.Success(r, loop);
// we can't supply just recv_start_callback in Receive
// because it will create a temporary delegate which could(and will) be garbage collected at any time
// happens in my case after 10 or 20 calls
// so we have to reference it, so it won't garbage collect it until the object itself
// is gone
recv_start_cb_win = recv_start_callback_w;
recv_start_cb_unix = recv_start_callback_u;
}
开发者ID:GamingAtheist,项目名称:LibuvSharp,代码行数:13,代码来源:Udp.cs
示例20: Open
public static void Open(Loop loop, string path, UVFileAccess access, Action<Exception, UVFile> callback)
{
var fsr = new FileSystemRequest(path);
fsr.Callback = (ex) => {
UVFile file = null;
if (fsr.Result != IntPtr.Zero) {
file = new UVFile(loop, fsr.Result.ToInt32());
}
Ensure.Success(ex, callback, file);
};
int r = uv_fs_open(loop.NativeHandle, fsr.Handle, path, (int)access, 0, FileSystemRequest.CallbackDelegate);
Ensure.Success(r);
}
开发者ID:lrdcasimir,项目名称:LibuvSharp,代码行数:13,代码来源:UVFile.cs
注:本文中的LibuvSharp.Loop类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论