Exemple #1
0
 public static void InvokeAsyncMethod(this Socket socket, Func <SocketAsyncEventArgs, bool> method, EventHandler <SocketAsyncEventArgs> callback, SocketAsyncEventArgs args, Action <Exception> errorCallback, Func <IAsyncFuture> closeSocketback)
 {
     try
     {
         if (!method(args))
         {
             callback.call(socket, args);
         }
     }
     catch (SocketException ex)
     {
         if (errorCallback != null)
         {
             errorCallback.call(ex);
         }
         if (closeSocketback != null)
         {
             closeSocketback.call();
         }
     }
     catch (Exception ex)
     {
         if (errorCallback != null)
         {
             errorCallback.call(ex);
         }
     }
 }
 public static string test()
 {
     try {
         throw new Exception("Message");
     } catch (Exception e) {
         Func f = () => e.getMessage();
         return(f.call());
     }
 }
Exemple #3
0
 public virtual void walk(Func c)
 {
     c.call(this);
     if (isDir())
     {
         List x = list();
         for (int i = 0; i < x.sz(); ++i)
         {
             ((File)x.get(i)).walk(c);
         }
     }
 }
    public static string test()
    {
        var result = "";

        foreach (var s in new ArrayList <string> {
            "a", "b", "c"
        })
        {
            Func f = () => s;
            result += f.call();
        }
        return(result);
    }
Exemple #5
0
 public virtual void walk(Func c)
 {
     c.call(this);
       if (isDir())
       {
     List x = list();
     for (int i=0; i<x.sz(); ++i)
       ((File)x.get(i)).walk(c);
       }
 }