Ejemplo n.º 1
0
        private IAsyncResult RemoteAsyncCallRead(TupleSpace space, ISchema schema, string id, int seq)
        {
            AsyncReadDelegate RemoteDel = new AsyncReadDelegate(space.Read);
            IAsyncResult      RemAr     = RemoteDel.BeginInvoke(schema, id, seq, null, null);

            return(RemAr);
        }
Ejemplo n.º 2
0
 public ITuple Read(ISchema schema, string id)
 {
     Seq++;
     while (true)
     {
         try {
             List <IAsyncResult> results = new List <IAsyncResult>();
             List <WaitHandle>   waits   = new List <WaitHandle>();
             //foreach (TupleSpace space in viewManager.RequestView().pingables)
             foreach (KeyValuePair <string, TupleSpace> entry in GetViews())
             {
                 IAsyncResult ar = RemoteAsyncCallRead(entry.Value, schema, id, Seq);
                 results.Add(ar);
                 waits.Add(ar.AsyncWaitHandle);
             }
             int index = WaitHandle.WaitAny(waits.ToArray(), 2000);
             if (index != WaitHandle.WaitTimeout)
             {
                 AsyncReadDelegate del = (AsyncReadDelegate)((AsyncResult)results[index]).AsyncDelegate;
                 return(del.EndInvoke(results[index])); //todo make function that endIvokes rest in another thread
             }
         } catch (Exception e) {
             continue;
         }
     }
 }