コード例 #1
0
    static void Main()
    {
        Console.WriteLine("Adding and calling a normal C++ callback");
        Console.WriteLine("----------------------------------------");

        Caller caller = new Caller();

        using (Callback callback = new Callback())
        {
            caller.setCallback(callback);
            caller.call();
            caller.resetCallback();
        }

        Console.WriteLine();
        Console.WriteLine("Adding and calling a C# callback");
        Console.WriteLine("------------------------------------");

        using (Callback callback = new CSharpCallback())
        {
            caller.setCallback(callback);
            caller.call();
            caller.resetCallback();
        }

        Console.WriteLine();
        Console.WriteLine("C# exit");
    }
コード例 #2
0
ファイル: runme.cs プロジェクト: kesmit13/swig
  static void Main() 
  {
    Console.WriteLine("Adding and calling a normal C++ callback");
    Console.WriteLine("----------------------------------------");

    Caller caller = new Caller();
    using (Callback callback = new Callback())
    {
      caller.setCallback(callback);
      caller.call();
      caller.resetCallback();
    }

    Console.WriteLine();
    Console.WriteLine("Adding and calling a C# callback");
    Console.WriteLine("------------------------------------");

    using (Callback callback = new CSharpCallback())
    {
      caller.setCallback(callback);
      caller.call();
      caller.resetCallback();
    }

    Console.WriteLine();
    Console.WriteLine("C# exit");
  }
コード例 #3
0
        private void Foo()
        {
            unsafe
            {
                ulong nwid = 0xabfd31bd47bef75e;
                int   err;

                _callback = new CSharpCallback(MyCallback);
                //var functionPointerForDelegate = Marshal.GetFunctionPointerForDelegate(_callback);
                var currentDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                var foo = zts_allow_local_conf(1);

                if ((err = zts_start(currentDirectory, _callback, 9994)) == 1)
                {
                    throw new Exception($"Failed to start/join network [{nwid:X}]");
                }
                Debug.WriteLine(err);
            }
        }
コード例 #4
0
 public static extern int zts_start(string path, CSharpCallback callback, int port);
コード例 #5
0
 // Use this for initialization
 void Start()
 {
     CSharpCallback.CallChainFromManaged(3, 5);
 }