Exemplo n.º 1
0
 public static void Continue(Primitive prim,
                             Primitive.Callback cb, int timeoutMs = -1)
 {
     Primitive.WhenSignalled(prim, (pr) =>
                             ThreadPool.QueueUserWorkItem((obj) => cb(pr)),
                             timeoutMs);
 }
Exemplo n.º 2
0
 // Reschedule the Gtk handler to be run when the primitive
 // becomes ready. This is only done if we need to do this and
 // the handler hasn't already been scheduled.
 void listen()
 {
     if (enabled && !listening)
     {
         Primitive.WhenSignalled(Primitive, (p) =>
                                 Gtk.Application.Invoke(gtkHandler));
     }
 }
Exemplo n.º 3
0
        public static Primitive Wait(Primitive[] prims,
                                     int timeoutMs = -1)
        {
            var s = new Sync();

            Primitive.WhenSignalled(prims, s.Send, timeoutMs);
            return(s.Recv());
        }
Exemplo n.º 4
0
        public static Task <Primitive> WaitAsync(Primitive[] prims,
                                                 int timeoutMs = -1)
        {
            var tsc = new TaskCompletionSource <Primitive>();

            Primitive.WhenSignalled(prims,
                                    (src) => tsc.SetResult(src), timeoutMs);

            return(tsc.Task);
        }