Esempio 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);
 }
Esempio 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));
     }
 }
Esempio 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());
        }
Esempio 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);
        }