Beispiel #1
0
        /// <summary>
        /// Pass Exceptions thrown during a mapping to the given <paramref name="callback"/> instead of throwing
        /// them, for all source and target types.
        /// </summary>
        /// <param name="callback">
        /// The callback to which to pass thrown Exception information. If the thrown exception should not be
        /// swallowed, it should be rethrown inside the callback.
        /// </param>
        /// <returns>
        /// An <see cref="IGlobalMappingSettings"/> with which to globally configure other mapping aspects.
        /// </returns>
        public IGlobalMappingSettings PassExceptionsTo(Action <IMappingExceptionData> callback)
        {
            var exceptionCallback = new ExceptionCallback(GlobalConfigInfo, callback.ToConstantExpression());

            MapperContext.UserConfigurations.Add(exceptionCallback);
            return(this);
        }
Beispiel #2
0
        public Form1()
        {
            bVista = (Environment.OSVersion.Version.Major == 6);

            // Required for Windows Form Designer support
            InitializeComponent();

            // Late setup of the CPU monitor - (Bails-out if in Vista)
            InitializePeformanceMonitor();

            // Hide the CPU load monitor if running in Windows Vista
            // Detecting the CPU load is a security violation in Vista
            CPULoadBox.Visible = !bVista;

            // Setup the callback routine for updating the UI
            updateUI = new UpdateUICallback(StatusUpdate);

            // Setup the callback routine for NullReference exception handling
            handleException = new ExceptionCallback(ThreadException);

            // Create the list of USB devices attached to the CyUSB3.sys driver.
            usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);

            //Assign event handlers for device attachment and device removal.
            usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached);
            usbDevices.DeviceRemoved  += new EventHandler(usbDevices_DeviceRemoved);

            //Set and search the device with VID-PID 04b4-1003 and if found, selects the end point
            SetDevice();
        }
Beispiel #3
0
        public IFullMappingSettings <TSource, TTarget> PassExceptionsTo(Action <IMappingExceptionData <TSource, TTarget> > callback)
        {
            var exceptionCallback = new ExceptionCallback(ConfigInfo, callback.ToConstantExpression());

            MapperContext.UserConfigurations.Add(exceptionCallback);
            return(this);
        }
Beispiel #4
0
        public ESeekM280Api()

        {
            usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);

            handleException = new ExceptionCallback(ThreadException);

            Img_View = new Image_View(ImageView);

            SetDevice();

            if (M280DEF.PixFormat == PixelFormat.Format16bppRgb565)
            {
                TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 2;
            }
            else if (M280DEF.PixFormat == PixelFormat.Format24bppRgb)
            {
                TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 3;
            }

            this.BufNum = TotalPixSize / (512 * M280DEF.Packet_Xfer);

            this.bInitM280 = false;
            this.bSysBusy  = false;
        }
Beispiel #5
0
        public IReactor NewReactor(INode listenAddress)
        {
            var reactor = NewReactorInternal(listenAddress);

            reactor.Configure(Config);

            if (ReceivedData != null)
            {
                reactor.OnReceive += (ReceivedDataCallback)ReceivedData.Clone();
            }
            if (ConnectionEstablishedCallback != null)
            {
                reactor.OnConnection += (ConnectionEstablishedCallback)ConnectionEstablishedCallback.Clone();
            }
            if (ConnectionTerminatedCallback != null)
            {
                reactor.OnDisconnection += (ConnectionTerminatedCallback)ConnectionTerminatedCallback.Clone();
            }
            if (ExceptionCallback != null)
            {
                reactor.OnError += (ExceptionCallback)ExceptionCallback.Clone();
            }

            return(reactor);
        }
 public bool RemoveExceptionHandler(ExceptionCallback handler)
 {
     lock (ExceptionHandlers)
     {
         return(ExceptionHandlers.Remove(handler));
     }
 }
 public void AddExceptionHandler(ExceptionCallback handler)
 {
     lock (ExceptionHandlers)
     {
         ExceptionHandlers.Add(handler);
     }
 }
Beispiel #8
0
            public void Logout(LogoutCallback callback = null, ExceptionCallback ExCal = null)
            {
                DSRESTCommand cmd = getConnection().CreateCommand();

                cmd.setRequestType(DSHTTPRequestType.GET);
                cmd.setText("TCompanyTweet.Logout");
                cmd.prepare(get_TCompanyTweet_Logout_Metadata());
                InternalConnectionDelegate LogoutDel = () =>
                {
                    if (callback != null)
                    {
                        try
                        {
                            callback.DynamicInvoke();
                        }
                        catch (Exception ex)
                        {
                            if (ExCal != null)
                            {
                                getConnection().syncContext.Send(new SendOrPostCallback(x => ExCal.DynamicInvoke(ex.InnerException)), null);
                            }
                            else
                            {
                                getConnection().syncContext.Send(new SendOrPostCallback(x => BaseExCal.DynamicInvoke(ex.InnerException)), null);
                            }
                        }
                    }
                };

                getConnection().execute(cmd, this, LogoutDel, ExCal);
            }
Beispiel #9
0
        public IConnection NewConnection(INode localEndpoint, INode remoteEndpoint)
        {
            var connection = CreateConnection(localEndpoint, remoteEndpoint);

            connection.Configure(Config);

            if (ReceivedData != null)
            {
                connection.Receive += (ReceivedDataCallback)ReceivedData.Clone();
            }
            if (ConnectionEstablishedCallback != null)
            {
                connection.OnConnection += (ConnectionEstablishedCallback)ConnectionEstablishedCallback.Clone();
            }
            if (ConnectionTerminatedCallback != null)
            {
                connection.OnDisconnection += (ConnectionTerminatedCallback)ConnectionTerminatedCallback.Clone();
            }
            if (ExceptionCallback != null)
            {
                connection.OnError += (ExceptionCallback)ExceptionCallback.Clone();
            }

            return(connection);
        }
Beispiel #10
0
            public void ConnectedUsers(ConnectedUsersCallback callback = null, ExceptionCallback ExCal = null)
            {
                DSRESTCommand cmd = getConnection().CreateCommand();

                cmd.setRequestType(DSHTTPRequestType.GET);
                cmd.setText("TCompanyTweet.ConnectedUsers");
                cmd.prepare(get_TCompanyTweet_ConnectedUsers_Metadata());
                InternalConnectionDelegate ConnectedUsersDel = () =>
                {
                    if (callback != null)
                    {
                        try
                        {
                            callback.DynamicInvoke((TJSONArray)cmd.getParameter(0).getValue().GetAsJSONValue());
                        }
                        catch (Exception ex)
                        {
                            if (ExCal != null)
                            {
                                getConnection().syncContext.Send(new SendOrPostCallback(x => ExCal.DynamicInvoke(ex.InnerException)), null);
                            }
                            else
                            {
                                getConnection().syncContext.Send(new SendOrPostCallback(x => BaseExCal.DynamicInvoke(ex.InnerException)), null);
                            }
                        }
                    }
                };

                getConnection().execute(cmd, this, ConnectedUsersDel, ExCal);
            }
Beispiel #11
0
            public unsafe OverlappedIOCallback(WaitCallback callback, ExceptionCallback exceptionCallback)
            {
                Overlapped overlapped = new Overlapped(0, 0, IntPtr.Zero, null);

                this.nativeOverlapped = overlapped.UnsafePack(new IOCompletionThunk(this.IOCallback, exceptionCallback).ThunkFrame, null);
                this.callback         = callback;
            }
        /// <summary>
        /// Pass Exceptions thrown during a mapping to the given <paramref name="callback"/> instead of throwing
        /// them, irrespective of source and target type.
        /// </summary>
        /// <param name="callback">
        /// The callback to which to pass thrown Exception information. If the thrown exception should not be
        /// swallowed, it should be rethrown inside the callback.
        /// </param>
        public void PassExceptionsTo(Action <IMappingExceptionData> callback)
        {
            var exceptionCallback = new ExceptionCallback(
                MappingConfigInfo.AllRuleSetsSourceTypesAndTargetTypes(_mapperContext),
                Expression.Constant(callback));

            _mapperContext.UserConfigurations.Add(exceptionCallback);
        }
Beispiel #13
0
        public void PassExceptionsTo(Action <IMappingExceptionData <TSource, TTarget> > callback)
        {
            var exceptionCallback = new ExceptionCallback(
                _configInfo.ForTargetType <TTarget>(),
                Expression.Constant(callback));

            _configInfo.MapperContext.UserConfigurations.Add(exceptionCallback);
        }
Beispiel #14
0
 public void Add(Action action, ExceptionCallback exceptionCallback)
 {
     lock (synchronizedQueueOfActions)
     {
         synchronizedQueueOfActions.Enqueue(new ActionAndCallback(action, exceptionCallback));
         waitEvent.Set();
     }
 }
        protected virtual void ReadFile()
        {
            while (true)
            {
                var next = Dequeue();

                if (next == null)
                {
                    Thread.Sleep(100);
                    continue;
                }

                try
                {
                    if (!lastPositionDict.ContainsKey(next))
                    {
                        lastPositionDict.Add(next, 0L);
                        fileStatistics.Add(next, new TailStatistics());
                    }

                    StartCallback?.Invoke(initialLoad);
                    var totalLineCount = 0;
                    var minLineCount   = 0;
                    var clear          = false;
                    using (var reader = readerFactory.CreateReader(next))
                    {
                        var loadLastLines = LoadLastLines();
                        if (initialLoad && loadLastLines >= 0 && lastPositionDict[next] == 0)
                        {
                            totalLineCount = reader.CountLines();
                            minLineCount   = totalLineCount > loadLastLines ? totalLineCount - loadLastLines : 0;
                        }

                        var lastPosition = lastPositionDict[next];

                        if (lastPosition > reader.Length)
                        {
                            lastPositionDict[next] = lastPosition = 0L;
                            fileStatistics[next].Reset();
                            initialLoad = true;
                            StartCallback?.Invoke(initialLoad);
                            clear = true;
                        }

                        reader.Seek(lastPosition);
                        ReadLines(reader, next, minLineCount, clear);
                        lastPositionDict[next] = reader.Position;
                    }

                    FinishCallback?.Invoke(initialLoad, fileStatistics[next]);
                    initialLoad = false;
                }
                catch (Exception ex)
                {
                    ExceptionCallback?.Invoke(ex);
                }
            }
        }
Beispiel #16
0
        public bool RemoveExceptionHandler(ExceptionCallback handler)
        {
            if (ExceptionHandlers == null)
            {
                return(false);
            }

            return(ExceptionHandlers.Remove(handler));
        }
Beispiel #17
0
        public void AddExceptionHandler(ExceptionCallback handler)
        {
            if (ExceptionHandlers == null)
            {
                ExceptionHandlers = new List <ExceptionCallback>();
            }

            ExceptionHandlers.Add(handler);
        }
Beispiel #18
0
 public ActionAndCallback(Action action, ExceptionCallback exceptionCallback)
 {
     if (action == null)
     {
         throw new ArgumentNullException("action");
     }
     this.action            = action;
     this.exceptionCallback = exceptionCallback;
 }
Beispiel #19
0
        public void Start()
        {
            //string url = "http://localhost:9000";
            //server = WebApp.Start(url);

            usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);

            // Setup the callback routine for NullReference exception handling
            handleException = new ExceptionCallback(ThreadException);

            // Setup the callback routine for Image view from M280 board
            Img_View = new Image_View(ImageView);

            //Assign event handlers for device attachment and device removal.
            usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached);
            usbDevices.DeviceRemoved  += new EventHandler(usbDevices_DeviceRemoved);

            //Associate handler with DataReceived Event - Sachin
            serPort.DataReceived += serPort_DataReceived;

            // Set Form name
            //ST: Comment as we move the code to service
            //this.Text = M280DEF.ProName + " - V" + M280DEF.SWver;


            //Set and search the device with VID-PID 04b4-1003 and if found, selects the end point
            SetDevice();

            //Initialize value
            if (M280DEF.PixFormat == PixelFormat.Format16bppRgb565)
            {
                TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 2;
            }
            else if (M280DEF.PixFormat == PixelFormat.Format24bppRgb)
            {
                TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 3;
            }

            if ((TotalPixSize % (512 * M280DEF.Packet_Xfer)) != 0)
            {
                //TODO: Write in event viewer
                //MessageBox.Show("Please check pixel size!");
            }

            this.BufNum = TotalPixSize / (512 * M280DEF.Packet_Xfer);

            //ST: Comment as we move the code to service
            //this.timCheckStatus.Tick += new EventHandler(CheckState_Tick);

            //ST: Comment as we move the code to service
            //this.timCheckStatus.Interval = M280DEF.StatusGetInterval;
            this.bInitM280 = false;
            this.bSysBusy  = false;

            openPort();
        }
Beispiel #20
0
 public void SetExceptionHandler(ExceptionCallback callback, IConnection connection)
 {
     _owner = connection;
     Exception = callback;
     _heliosException = exception =>
     {
         if (Exception != null)
             Exception(exception, _owner);
     };
     Scheduler.SwapExecutor(new TryCatchExecutor(_heliosException)); //pipes errors back to the connection object
 }
Beispiel #21
0
 /// <summary>
 /// Отправить ошибку парса в основную прогу немедленно [асинхронно]
 /// [реализовано через callback, чтобы редкие виды ошибок не приводили к неотправке самого списка ошибок]
 /// </summary>
 /// <param name="name">Название\описание ошибки</param>
 /// <param name="path">Путь до ошибки. Реализовано в виде строки можно было тонко описать момент её возникновения</param>
 /// <param name="data">Любые прикладные данные этой ошибки, которые вам нужно будет знать для её исправления. Будет сериализовано в json и записано.</param>
 public void sendException(string name, string path = "", object data = null)
 {
     if (ExceptionCallback != null)
     {
         ExceptionCallback.BeginInvoke(name, path, data, (iResult) =>
         {
             ExceptionCallback.EndInvoke(iResult);
         },
                                       null);
     }
 }
Beispiel #22
0
 /// <summary>
 /// Creates a new exception callbacks structure.
 /// </summary>
 /// <remarks>
 /// All handlers are optional, and if null, the CPU will just continue executing as if nothing happened.
 /// </remarks>
 /// <param name="interruptCallback">Handler for CPU interrupts triggered using <see cref="IExecutionContext.RequestInterrupt"/></param>
 /// <param name="breakCallback">Handler for CPU software interrupts caused by the Arm BRK instruction</param>
 /// <param name="supervisorCallback">Handler for CPU software interrupts caused by the Arm SVC instruction</param>
 /// <param name="undefinedCallback">Handler for CPU software interrupts caused by any undefined Arm instruction</param>
 public ExceptionCallbacks(
     ExceptionCallbackNoArgs interruptCallback = null,
     ExceptionCallback breakCallback           = null,
     ExceptionCallback supervisorCallback      = null,
     ExceptionCallback undefinedCallback       = null)
 {
     InterruptCallback  = interruptCallback;
     BreakCallback      = breakCallback;
     SupervisorCallback = supervisorCallback;
     UndefinedCallback  = undefinedCallback;
 }
Beispiel #23
0
        public WorkerThread(ExceptionCallback defaultExceptionCallback)
        {
            this.waitEvent = new ManualResetEvent(false);
            this.defaultExceptionCallback   = defaultExceptionCallback;
            this.synchronizedQueueOfActions = new Queue <ActionAndCallback>();
            this.keepRunning = true;
            Thread thread = new Thread(Run);

            thread.IsBackground = true;
            thread.Start();
        }
Beispiel #24
0
 public void SetExceptionHandler(ExceptionCallback callback, IConnection connection)
 {
     _owner           = connection;
     Exception        = callback;
     _heliosException = exception =>
     {
         if (Exception != null)
         {
             Exception(exception, _owner);
         }
     };
     Scheduler.SwapExecutor(new TryCatchExecutor(_heliosException)); //pipes errors back to the connection object
 }
Beispiel #25
0
            public IOCompletionThunk(IOCompletionCallback callback, ExceptionCallback exceptionCallback)
            {
                if (callback == null)
                {
                    throw new ArgumentNullException("callback");
                }
                if (exceptionCallback == null)
                {
                    throw new ArgumentNullException("exceptionCallback");
                }

                this.callback          = callback;
                this.exceptionCallback = exceptionCallback;
            }
Beispiel #26
0
        public Form1()
        {
            InitializeComponent();

            // For USB Camera
            // Create the list of USB devices attached to the CyUSB.sys driver.
            usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);

            // Setup the callback routine for NullReference exception handling
            handleException = new ExceptionCallback(ThreadException);

            // Setup the callback routine for Image view from M280 board
            Img_View = new Image_View(ImageView);

            //Assign event handlers for device attachment and device removal.
            usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached);
            usbDevices.DeviceRemoved  += new EventHandler(usbDevices_DeviceRemoved);

            //Associate handler with DataReceived Event - Sachin
            serPort.DataReceived += serPort_DataReceived;

            // Set Form name
            this.Text = M280DEF.ProName + " - V" + M280DEF.SWver;

            //Set and search the device with VID-PID 04b4-1003 and if found, selects the end point
            SetDevice();

            //Initialize value
            if (M280DEF.PixFormat == PixelFormat.Format16bppRgb565)
            {
                TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 2;
            }
            else if (M280DEF.PixFormat == PixelFormat.Format24bppRgb)
            {
                TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 3;
            }

            if ((TotalPixSize % (512 * M280DEF.Packet_Xfer)) != 0)
            {
                MessageBox.Show("Please check pixel size!");
            }

            this.BufNum = TotalPixSize / (512 * M280DEF.Packet_Xfer);
            this.timCheckStatus.Tick    += new EventHandler(CheckState_Tick);
            this.timCheckStatus.Interval = M280DEF.StatusGetInterval;
            this.bInitM280 = false;
            this.bSysBusy  = false;
            openPort();
        }
Beispiel #27
0
        public static void SendPacket(Socket socket, Packet p, ExceptionCallback excCall)
        {
            try
            {
                byte[] data = PacketHandler.SerializePacket(p);

                socket.SendBufferSize = data.Length;
                socket.Send(BitConverter.GetBytes(data.Length), 0, 4, 0); //byte Anzahl senden
                socket.Send(data);                                        //byte array senden
            }
            catch (Exception exc)
            {
                excCall(socket, exc);
                return;
            }
        }
 public M280(string commPort = "")
 {
     readerdata = string.Empty;
     commport   = commPort;
     dlfile     = new DLFILE();
     dispatcher = Dispatcher.CurrentDispatcher;
     dispatcher.Thread.Priority = ThreadPriority.Highest;
     captureutility             = new CaptureUtility();
     Initialized           = null;
     Captured              = null;
     DeviceAttached        = null;
     DeviceDetached        = null;
     ReceiveData           = null;
     handleException       = Thread_Exception;
     imageview             = Image_Captured;
     checkstatus           = new System.Timers.Timer();
     checkstatus.AutoReset = false;
     checkstatus.Elapsed  += CheckState_Tick;
     checkstatus.Interval  = M280DEF.StatusGetInterval;
     capture           = new System.Timers.Timer();
     capture.AutoReset = false;
     capture.Elapsed  += Capture_Tick;
     capture.Interval  = 500;
     bulkendpoint      = null;
     controlendpoint   = null;
     deviceready       = false;
     release           = true;
     running           = false;
     scannerconnected  = false;
     devicebusy        = true;
     deskew            = true;
     m280status        = new byte[M280DEF.STATUS_SIZE];
     pixelformat       = PixelFormat.Format16bppRgb565;
     totalpixelsize    = 0;
     InitializePixelSize();
     buffernum     = totalpixelsize / (512 * M280DEF.Packet_Xfer);
     buffersize    = 0;
     queuesize     = 0;
     successes     = 0;
     failures      = 0;
     transferbytes = 0;
     disposed      = false;
     GetUsbDevices();
     InitializeScanner();
     InitializeReader();
     onInitialized();
 }
        public static void ScheduleCallback(WaitCallback callback, ExceptionCallback exceptionCallback, object state)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            object workItemState = state;
            lock (mutex)
            {
                managedCallbacks.Enqueue(new ManagedCallback(callback, exceptionCallback, workItemState));
                if (!isCompletionQueued)
                {
                    QueueCompletionCallback();
                }
            }
        }
Beispiel #30
0
 private static void ExecuteAsyncInternal(WaitCallback callback, ExceptionCallback exceptionCallback)
 {
     try
     {
         callback(null);
     }
     catch (Exception e)
     {
         if (exceptionCallback != null)
         {
             exceptionCallback(e);
         }
         else
         {
             LogUtil.LogError(e);
         }
     }
 }
 private static void ExecuteAsyncInternal(WaitCallback callback, ExceptionCallback exceptionCallback)
 {
     try
     {
         callback(null);
     }
     catch (Exception e)
     {
         if (exceptionCallback != null)
         {
             exceptionCallback(e);
         }
         else
         {
             LogUtil.LogError(e);
         }
     }
 }
Beispiel #32
0
        public static void ScheduleCallback(WaitCallback callback, ExceptionCallback exceptionCallback, object state)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            object workItemState = state;

            lock (mutex)
            {
                managedCallbacks.Enqueue(new ManagedCallback(callback, exceptionCallback, workItemState));
                if (!isCompletionQueued)
                {
                    QueueCompletionCallback();
                }
            }
        }
Beispiel #33
0
        public static void ExecuteAsync(this IAsyncRunner runner, AsyncRunType runType, WaitCallback callback, ExceptionCallback exceptionCallback)
        {
            if (runType == AsyncRunType.ThreadPool)
            {
                ThreadPool.QueueUserWorkItem(delegate
                {
                    ExecuteAsyncInternal(callback, exceptionCallback);
                });
            }
            else
            {
                Thread newThread = new Thread(new ParameterizedThreadStart(ExecuteAsyncStart));
                newThread.Start(new ExecuteAsyncThreadStartParameter
                    {
                        RunCallback = callback,
                        ExceptionCallback = exceptionCallback
                    });

            }
        }
Beispiel #34
0
        //Clientdata thread receives data from Clients
        public static void Data_IN(object cSocket, DataManagerCallback dataCallback, ExceptionCallback excCallback)
        {
            Socket socket = (Socket)cSocket;

            //Packete werden aufgeteilt und nacheinander gesendet/empfangen
            SocketError error = SocketError.Success;

            try
            {
                while (socket.Connected)
                {
                    byte[] sizeBuf = new byte[4];

                    int byteLenngth = socket.Receive(sizeBuf, 0, sizeBuf.Length, SocketFlags.None, out error);

                    if (error == SocketError.Success && byteLenngth > 0)
                    {
                        uint size = BitConverter.ToUInt32(sizeBuf, 0); //bytes to Int

                        Packet p = Read_Data_Stream(socket, size);     //Read_Data_Stream(clientSocket, size);

                        if (p != null)
                        {
                            dataCallback(p);  //an Hauptklasse weiterleiten
                        }
                    }
                    else
                    {
                        throw new Exception("Socket disconnected!");
                    }
                }
            }
            catch (Exception exp)
            {
                excCallback(socket, exp);
                return;
            }
        }
Beispiel #35
0
        public CypressDataAcq()
        {
            PPX = 64;
            QueueSz = 64;

            // Setup the callback routine for updating the UI
            updateUI = new UpdateUICallback(StatusUpdate);

            // Setup the callback routine for NullReference exception handling
            handleException = new ExceptionCallback(ThreadException);

            // Create the list of USB devices attached to the CyUSB.sys driver.
            usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);

            //Assign event handlers for device attachment and device removal.
            usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached);
            usbDevices.DeviceRemoved += new EventHandler(usbDevices_DeviceRemoved);

            //Set and search the device with VID-PID 04b4-1003 and if found, selects the end point
            SetDevice();

            TransferStatusText = "Acquisition Not Active";
        }
Beispiel #36
0
 public void UnregisterClientCallback(String ChannelId, String CallbackId, String SecurityToken, UnregisterClientCallbackCallback callback = null, ExceptionCallback ExCal = null)
 {
     DSRESTCommand cmd = getConnection().CreateCommand();
     cmd.setRequestType(DSHTTPRequestType.GET);
     cmd.setText("DSAdmin.UnregisterClientCallback");
     cmd.prepare(get_DSAdmin_UnregisterClientCallback_Metadata());
     UnregisterClientCallbackDelegate UnregisterClientCallbackDel = () => {
       if (callback != null)
       {
     callback.DynamicInvoke(cmd.getParameter(3).getValue().GetAsBoolean());
       }
     };
     cmd.getParameter(0).getValue().SetAsString(ChannelId);
     cmd.getParameter(1).getValue().SetAsString(CallbackId);
     cmd.getParameter(2).getValue().SetAsString(SecurityToken);
     getConnection().execute(cmd, this, UnregisterClientCallbackDel, ExCal);
 }
Beispiel #37
0
 public static void ExecuteAsync(this IAsyncRunner runner, WaitCallback callback, ExceptionCallback exceptionCallback)
 {
     runner.ExecuteAsync(AsyncRunType.ThreadPool, callback, exceptionCallback);
 }
Beispiel #38
0
 public new ClientBootstrap OnError(ExceptionCallback exceptionCallback)
 {
     base.OnError(exceptionCallback);
     return this;
 }
Beispiel #39
0
 public void FindMethods(String PackageName, String ClassPattern, String MethodPattern, FindMethodsCallback callback = null, ExceptionCallback ExCal = null)
 {
     DSRESTCommand cmd = getConnection().CreateCommand();
     cmd.setRequestType(DSHTTPRequestType.GET);
     cmd.setText("DSAdmin.FindMethods");
     cmd.prepare(get_DSAdmin_FindMethods_Metadata());
     FindMethodsDelegate FindMethodsDel = () => {
       if (callback != null)
       {
     callback.DynamicInvoke((TDBXReader)cmd.getParameter(3).getValue().GetAsTable());
       }
     };
     cmd.getParameter(0).getValue().SetAsString(PackageName);
     cmd.getParameter(1).getValue().SetAsString(ClassPattern);
     cmd.getParameter(2).getValue().SetAsString(MethodPattern);
     getConnection().execute(cmd, this, FindMethodsDel, ExCal);
 }
Beispiel #40
0
 public void ClearResources(ClearResourcesCallback callback = null, ExceptionCallback ExCal = null)
 {
     DSRESTCommand cmd = getConnection().CreateCommand();
     cmd.setRequestType(DSHTTPRequestType.GET);
     cmd.setText("DSAdmin.ClearResources");
     cmd.prepare(get_DSAdmin_ClearResources_Metadata());
     ClearResourcesDelegate ClearResourcesDel = () => {
       if (callback != null)
       {
     callback.DynamicInvoke(cmd.getParameter(0).getValue().GetAsBoolean());
       }
     };
     getConnection().execute(cmd, this, ClearResourcesDel, ExCal);
 }
Beispiel #41
0
    public static void allTests(Ice.Communicator communicator, bool collocated)
#endif
    {
#if SILVERLIGHT
        bool collocated = false;
#endif
        string sref = "test:default -p 12010";
        Ice.ObjectPrx obj = communicator.stringToProxy(sref);
        test(obj != null);

        Test.TestIntfPrx p = Test.TestIntfPrxHelper.uncheckedCast(obj);

        sref = "testController:default -p 12011";
        obj = communicator.stringToProxy(sref);
        test(obj != null);

        Test.TestIntfControllerPrx testController = Test.TestIntfControllerPrxHelper.uncheckedCast(obj);

        Write("testing begin/end invocation... ");
        Flush();
        {
            Ice.AsyncResult result;
            Dictionary<string, string> ctx = new Dictionary<string, string>();

            result = p.begin_ice_isA("::Test::TestIntf");
            test(p.end_ice_isA(result));
            result = p.begin_ice_isA("::Test::TestIntf", ctx);
            test(p.end_ice_isA(result));

            result = p.begin_ice_ping();
            p.end_ice_ping(result);
            result = p.begin_ice_ping(ctx);
            p.end_ice_ping(result);

            result = p.begin_ice_id();
            test(p.end_ice_id(result).Equals("::Test::TestIntf"));
            result = p.begin_ice_id(ctx);
            test(p.end_ice_id(result).Equals("::Test::TestIntf"));

            result = p.begin_ice_ids();
            test(p.end_ice_ids(result).Length == 2);
            result = p.begin_ice_ids(ctx);
            test(p.end_ice_ids(result).Length == 2);

            if(!collocated)
            {
                result = p.begin_ice_getConnection();
                test(p.end_ice_getConnection(result) != null);
            }

            result = p.begin_op();
            p.end_op(result);
            result = p.begin_op(ctx);
            p.end_op(result);

            result = p.begin_opWithResult();
            test(p.end_opWithResult(result) == 15);
            result = p.begin_opWithResult(ctx);
            test(p.end_opWithResult(result) == 15);

            result = p.begin_opWithUE();
            try
            {
                p.end_opWithUE(result);
                test(false);
            }
            catch(Test.TestIntfException)
            {
            }
            result = p.begin_opWithUE(ctx);
            try
            {
                p.end_opWithUE(result);
                test(false);
            }
            catch(Test.TestIntfException)
            {
            }
        }
        WriteLine("ok");

        Write("testing async callback... ");
        Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            Dictionary<string, string> ctx = new Dictionary<string, string>();
            Cookie cookie = new Cookie(5);
            AsyncCallback cbWC = new AsyncCallback(cookie);

            p.begin_ice_isA("::Test::TestIntf", cb.isA, null);
            cb.check();
            p.begin_ice_isA("::Test::TestIntf", cbWC.isA, cookie);
            cbWC.check();
            p.begin_ice_isA("::Test::TestIntf", ctx, cb.isA, null);
            cb.check();
            p.begin_ice_isA("::Test::TestIntf", ctx, cbWC.isA, cookie);
            cbWC.check();

            p.begin_ice_ping(cb.ping, null);
            cb.check();
            p.begin_ice_ping(cbWC.ping, cookie);
            cbWC.check();
            p.begin_ice_ping(ctx, cb.ping, null);
            cb.check();
            p.begin_ice_ping(ctx, cbWC.ping, cookie);
            cbWC.check();

            p.begin_ice_id(cb.id, null);
            cb.check();
            p.begin_ice_id(cbWC.id, cookie);
            cbWC.check();
            p.begin_ice_id(ctx, cb.id, null);
            cb.check();
            p.begin_ice_id(ctx, cbWC.id, cookie);
            cbWC.check();

            p.begin_ice_ids(cb.ids, null);
            cb.check();
            p.begin_ice_ids(cbWC.ids, cookie);
            cbWC.check();
            p.begin_ice_ids(ctx, cb.ids, null);
            cb.check();
            p.begin_ice_ids(ctx, cbWC.ids, cookie);
            cbWC.check();

            if(!collocated)
            {
                p.begin_ice_getConnection(cb.connection, null);
                cb.check();
                p.begin_ice_getConnection(cbWC.connection, cookie);
                cbWC.check();
            }

            p.begin_op(cb.op, null);
            cb.check();
            p.begin_op(cbWC.op, cookie);
            cbWC.check();
            p.begin_op(ctx, cb.op, null);
            cb.check();
            p.begin_op(ctx, cbWC.op, cookie);
            cbWC.check();

            p.begin_opWithResult(cb.opWithResult, null);
            cb.check();
            p.begin_opWithResult(cbWC.opWithResult, cookie);
            cbWC.check();
            p.begin_opWithResult(ctx, cb.opWithResult, null);
            cb.check();
            p.begin_opWithResult(ctx, cbWC.opWithResult, cookie);
            cbWC.check();

            p.begin_opWithUE(cb.opWithUE, null);
            cb.check();
            p.begin_opWithUE(cbWC.opWithUE, cookie);
            cbWC.check();
            p.begin_opWithUE(ctx, cb.opWithUE, null);
            cb.check();
            p.begin_opWithUE(ctx, cbWC.opWithUE, cookie);
            cbWC.check();
        }
        WriteLine("ok");

        Write("testing response callback... ");
        Flush();
        {
            ResponseCallback cb = new ResponseCallback();
            Dictionary<string, string> ctx = new Dictionary<string, string>();

            p.begin_ice_isA("::Test::TestIntf").whenCompleted(cb.isA, null);
            cb.check();
            p.begin_ice_isA("::Test::TestIntf", ctx).whenCompleted(cb.isA, null);
            cb.check();

            p.begin_ice_ping().whenCompleted(cb.ping, null);
            cb.check();
            p.begin_ice_ping(ctx).whenCompleted(cb.ping, null);
            cb.check();

            p.begin_ice_id().whenCompleted(cb.id, null);
            cb.check();
            p.begin_ice_id(ctx).whenCompleted(cb.id, null);
            cb.check();

            p.begin_ice_ids().whenCompleted(cb.ids, null);
            cb.check();
            p.begin_ice_ids(ctx).whenCompleted(cb.ids, null);
            cb.check();

            if(!collocated)
            {
                p.begin_ice_getConnection().whenCompleted(cb.connection, null);
                cb.check();
            }

            p.begin_op().whenCompleted(cb.op, null);
            cb.check();
            p.begin_op(ctx).whenCompleted(cb.op, null);
            cb.check();

            p.begin_opWithResult().whenCompleted(cb.opWithResult, null);
            cb.check();
            p.begin_opWithResult(ctx).whenCompleted(cb.opWithResult, null);
            cb.check();

            p.begin_opWithUE().whenCompleted(cb.op, cb.opWithUE);
            cb.check();
            p.begin_opWithUE(ctx).whenCompleted(cb.op, cb.opWithUE);
            cb.check();
        }
        WriteLine("ok");

        Write("testing lambda callback... ");
        Flush();
        {
            ResponseCallback cb = new ResponseCallback();
            Dictionary<string, string> ctx = new Dictionary<string, string>();

            p.begin_ice_isA("::Test::TestIntf").whenCompleted(
                (bool r) =>
                {
                    cb.isA(r);
                }, null);
            cb.check();
            p.begin_ice_isA("::Test::TestIntf", ctx).whenCompleted(
                (bool r) =>
                {
                    cb.isA(r);
                }, null);
            cb.check();

            p.begin_ice_ping().whenCompleted(
                () =>
                {
                    cb.ping();
                }, null);
            cb.check();
            p.begin_ice_ping(ctx).whenCompleted(
                () =>
                {
                    cb.ping();
                }, null);
            cb.check();

            p.begin_ice_id().whenCompleted(
                (string id) =>
                {
                    cb.id(id);
                }, null);
            cb.check();
            p.begin_ice_id(ctx).whenCompleted(
                (string id) =>
                {
                    cb.id(id);
                }, null);
            cb.check();

            p.begin_ice_ids().whenCompleted(
                (string[] ids) =>
                {
                    cb.ids(ids);
                }, null);
            cb.check();
            p.begin_ice_ids(ctx).whenCompleted(
                (string[] ids) =>
                {
                    cb.ids(ids);
                }, null);
            cb.check();

            if(!collocated)
            {
                p.begin_ice_getConnection().whenCompleted(
                    (Ice.Connection conn) =>
                    {
                        cb.connection(conn);
                    }, null);
                cb.check();
            }

            p.begin_op().whenCompleted(
                () =>
                {
                    cb.op();
                }, null);
            cb.check();
            p.begin_op(ctx).whenCompleted(
                () =>
                {
                    cb.op();
                }, null);
            cb.check();

            p.begin_opWithResult().whenCompleted(
                (int r) =>
                {
                    cb.opWithResult(r);
                }, null);
            cb.check();
            p.begin_opWithResult(ctx).whenCompleted(
                (int r) =>
                {
                    cb.opWithResult(r);
                }, null);
            cb.check();

            p.begin_opWithUE().whenCompleted(
                () =>
                {
                    cb.op();
                },
                (Ice.Exception ex) =>
                {
                    cb.opWithUE(ex);
                });
            cb.check();
            p.begin_opWithUE(ctx).whenCompleted(
                () =>
                {
                    cb.op();
                },
                (Ice.Exception ex) =>
                {
                    cb.opWithUE(ex);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("testing local exceptions... ");
        Flush();
        {
            Test.TestIntfPrx indirect = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy"));
            Ice.AsyncResult r;

            r = indirect.begin_op();
            try
            {
                indirect.end_op(r);
                test(false);
            }
            catch(Ice.NoEndpointException)
            {
            }


            try
            {
                r = ((Test.TestIntfPrx)p.ice_oneway()).begin_opWithResult();
                test(false);
            }
            catch(System.ArgumentException)
            {
            }

            //
            // Check that CommunicatorDestroyedException is raised directly.
            //
            if(p.ice_getConnection() != null)
            {
                Ice.InitializationData initData = new Ice.InitializationData();
                initData.properties = communicator.getProperties().ice_clone_();
                Ice.Communicator ic = Ice.Util.initialize(initData);
                Ice.ObjectPrx o = ic.stringToProxy(p.ToString());
                Test.TestIntfPrx p2 = Test.TestIntfPrxHelper.checkedCast(o);
                ic.destroy();
                
                try
                {
                    p2.begin_op();
                    test(false);
                }
                catch(Ice.CommunicatorDestroyedException)
                {
                    // Expected.
                }
            }
        }
        WriteLine("ok");

        Write("testing local exceptions with async callback... ");
        Flush();
        {
            Test.TestIntfPrx i = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy"));
            AsyncCallback cb = new AsyncCallback();
            Cookie cookie = new Cookie(5);
            AsyncCallback cbWC = new AsyncCallback(cookie);

            i.begin_ice_isA("::Test::TestIntf", cb.isAEx, null);
            cb.check();
            i.begin_ice_isA("::Test::TestIntf", cbWC.isAEx, cookie);
            cbWC.check();

            i.begin_ice_ping(cb.pingEx, null);
            cb.check();
            i.begin_ice_ping(cbWC.pingEx, cookie);
            cbWC.check();

            i.begin_ice_id(cb.idEx, null);
            cb.check();
            i.begin_ice_id(cbWC.idEx, cookie);
            cbWC.check();

            i.begin_ice_ids(cb.idsEx, null);
            cb.check();
            i.begin_ice_ids(cbWC.idsEx, cookie);
            cbWC.check();

            if(!collocated)
            {
                i.begin_ice_getConnection(cb.connectionEx, null);
                cb.check();
                i.begin_ice_getConnection(cbWC.connectionEx, cookie);
                cbWC.check();
            }

            i.begin_op(cb.opEx, null);
            cb.check();
            i.begin_op(cbWC.opEx, cookie);
            cbWC.check();
        }
        WriteLine("ok");

        Write("testing local exceptions with response callback... ");
        Flush();
        {
            Test.TestIntfPrx i = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy"));
            ExceptionCallback cb = new ExceptionCallback();

            i.begin_ice_isA("::Test::TestIntf").whenCompleted(cb.isA, cb.ex);
            cb.check();

            i.begin_ice_ping().whenCompleted(cb.ping, cb.ex);
            cb.check();

            i.begin_ice_id().whenCompleted(cb.id, cb.ex);
            cb.check();

            i.begin_ice_ids().whenCompleted(cb.ids, cb.ex);
            cb.check();

            if(!collocated)
            {
                i.begin_ice_getConnection().whenCompleted(cb.connection, cb.ex);
                cb.check();
            }

            i.begin_op().whenCompleted(cb.op, cb.ex);
            cb.check();
        }
        WriteLine("ok");

        Write("testing local exceptions with lambda callback... ");
        Flush();
        {
            Test.TestIntfPrx i = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy"));
            ExceptionCallback cb = new ExceptionCallback();

            i.begin_ice_isA("::Test::TestIntf").whenCompleted(
                (bool r) =>
                {
                    cb.isA(r);
                },
                (Ice.Exception ex) =>
                {
                    cb.ex(ex);
                });
            cb.check();

            i.begin_ice_ping().whenCompleted(
                () =>
                {
                    cb.ping();
                },
                (Ice.Exception ex) =>
                {
                    cb.ex(ex);
                });
            cb.check();

            i.begin_ice_id().whenCompleted(
                (string id) =>
                {
                    cb.id(id);
                },
                (Ice.Exception ex) =>
                {
                    cb.ex(ex);
                });
            cb.check();

            i.begin_ice_ids().whenCompleted(
                (string[] ids) =>
                {
                    cb.ids(ids);
                },
                (Ice.Exception ex) =>
                {
                    cb.ex(ex);
                });
            cb.check();

            if(!collocated)
            {
                i.begin_ice_getConnection().whenCompleted(
                    (Ice.Connection conn) =>
                    {
                        cb.connection(conn);
                    },
                    (Ice.Exception ex) =>
                    {
                        cb.ex(ex);
                    });
                cb.check();
            }

            i.begin_op().whenCompleted(
                () =>
                {
                    cb.op();
                },
                (Ice.Exception ex) =>
                {
                    cb.ex(ex);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("testing exception callback... ");
        Flush();
        {
            Test.TestIntfPrx i = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy"));
            ExceptionCallback cb = new ExceptionCallback();

            i.begin_ice_isA("::Test::TestIntf").whenCompleted(cb.ex);
            cb.check();

            i.begin_op().whenCompleted(cb.ex);
            cb.check();

            i.begin_opWithResult().whenCompleted(cb.ex);
            cb.check();

            i.begin_opWithUE().whenCompleted(cb.ex);
            cb.check();

            // Ensures no exception is called when response is received
            p.begin_ice_isA("::Test::TestIntf").whenCompleted(cb.noEx);
            p.begin_op().whenCompleted(cb.noEx);
            p.begin_opWithResult().whenCompleted(cb.noEx);

            // If response is a user exception, it should be received.
            p.begin_opWithUE().whenCompleted(cb.opWithUE);
            cb.check();
        }
        WriteLine("ok");

        Write("testing lambda exception callback... ");
        Flush();
        {
            Test.TestIntfPrx i = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy"));
            ExceptionCallback cb = new ExceptionCallback();

            i.begin_ice_isA("::Test::TestIntf").whenCompleted(
                (Ice.Exception ex) =>
                {
                    cb.ex(ex);
                });
            cb.check();

            i.begin_op().whenCompleted(
                (Ice.Exception ex) =>
                {
                    cb.ex(ex);
                });

            cb.check();

            i.begin_opWithResult().whenCompleted(
                (Ice.Exception ex) =>
                {
                    cb.ex(ex);
                });
            cb.check();

            i.begin_opWithUE().whenCompleted(
                (Ice.Exception ex) =>
                {
                    cb.ex(ex);
                });
            cb.check();

            // Ensures no exception is called when response is received
            p.begin_ice_isA("::Test::TestIntf").whenCompleted(
                (Ice.Exception ex) =>
                {
                    cb.noEx(ex);
                });
            p.begin_op().whenCompleted(
                 (Ice.Exception ex) =>
                {
                    cb.noEx(ex);
                });
            p.begin_opWithResult().whenCompleted(
                 (Ice.Exception ex) =>
                {
                    cb.noEx(ex);
                });

            // If response is a user exception, it should be received.
            p.begin_opWithUE().whenCompleted(
                 (Ice.Exception ex) =>
                {
                    cb.opWithUE(ex);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("testing sent callback... ");
        Flush();
        {
            SentCallback cb = new SentCallback();

            p.begin_ice_isA("").whenCompleted(cb.isA, cb.ex).whenSent(cb.sent);
            cb.check();

            p.begin_ice_ping().whenCompleted(cb.ping, cb.ex).whenSent(cb.sent);
            cb.check();

            p.begin_ice_id().whenCompleted(cb.id, cb.ex).whenSent(cb.sent);
            cb.check();

            p.begin_ice_ids().whenCompleted(cb.ids, cb.ex).whenSent(cb.sent);
            cb.check();

            p.begin_op().whenCompleted(cb.op, cb.ex).whenSent(cb.sent);
            cb.check();

            p.begin_op(cb.opAsync, null).whenSent(cb.sentAsync);
            cb.check();

            p.begin_op().whenCompleted(cb.ex).whenSent(cb.sent);
            cb.check();

            List<SentCallback> cbs = new List<SentCallback>();
            byte[] seq = new byte[10024];
            (new System.Random()).NextBytes(seq);
            testController.holdAdapter();
            try
            {
                Ice.AsyncResult r;
                do
                {
                    SentCallback cb2 = new SentCallback();
                    r = p.begin_opWithPayload(seq).whenCompleted(cb2.ex).whenSent(cb2.sent);
                    cbs.Add(cb2);
                }
                while(r.sentSynchronously());
            }
            finally
            {
                testController.resumeAdapter();
            }
            foreach(SentCallback cb3 in cbs)
            {
                cb3.check();
            }
        }
        WriteLine("ok");

        Write("testing lambda sent callback... ");
        Flush();
        {
            SentCallback cb = new SentCallback();

            p.begin_ice_isA("").whenCompleted(
                (bool r) =>
                {
                    cb.isA(r);
                },
                (Ice.Exception ex) =>
                {
                    cb.ex(ex);
                }
            ).whenSent(
                (bool sentSynchronously) =>
                {
                    cb.sent(sentSynchronously);
                });
            cb.check();

            p.begin_ice_ping().whenCompleted(
                () =>
                {
                    cb.ping();
                },
                (Ice.Exception ex) =>
                {
                    cb.ex(ex);
                }
            ).whenSent(
                (bool sentSynchronously) =>
                {
                    cb.sent(sentSynchronously);
                });
            cb.check();

            p.begin_ice_id().whenCompleted(
                (string id) =>
                {
                    cb.id(id);
                },
                (Ice.Exception ex) =>
                {
                    cb.ex(ex);
                }
            ).whenSent(
                (bool sentSynchronously) =>
                {
                    cb.sent(sentSynchronously);
                });
            cb.check();

            p.begin_ice_ids().whenCompleted(
                (string[] ids) =>
                {
                    cb.ids(ids);
                },
                (Ice.Exception ex) =>
                {
                    cb.ex(ex);
                }
            ).whenSent(
                (bool sentSynchronously) =>
                {
                    cb.sent(sentSynchronously);
                });
            cb.check();

            p.begin_op().whenCompleted(
                () =>
                {
                    cb.op();
                },
                (Ice.Exception ex) =>
                {
                    cb.ex(ex);
                }
            ).whenSent(
                (bool sentSynchronously) =>
                {
                    cb.sent(sentSynchronously);
                });
            cb.check();

            p.begin_op(cb.opAsync, null).whenSent(
                (Ice.AsyncResult r) =>
                {
                    cb.sentAsync(r);
                });
            cb.check();

            p.begin_op().whenCompleted(
                (Ice.Exception ex) =>
                {
                    cb.ex(ex);
                }
            ).whenSent(
                (bool sentSynchronously) =>
                {
                    cb.sent(sentSynchronously);
                });
            cb.check();

            List<SentCallback> cbs = new List<SentCallback>();
            byte[] seq = new byte[10024];
            (new System.Random()).NextBytes(seq);
            testController.holdAdapter();
            try
            {
                Ice.AsyncResult r;
                do
                {
                    SentCallback cb2 = new SentCallback();
                    r = p.begin_opWithPayload(seq).whenCompleted(
                        (Ice.Exception ex) =>
                        {
                            cb2.ex(ex);
                        }
                    ).whenSent(
                        (bool sentSynchronously) =>
                        {
                            cb2.sent(sentSynchronously);
                        });
                    cbs.Add(cb2);
                }
                while(r.sentSynchronously());
            }
            finally
            {
                testController.resumeAdapter();
            }
            foreach(SentCallback cb3 in cbs)
            {
                cb3.check();
            }
        }
        WriteLine("ok");

        Write("testing illegal arguments... ");
        Flush();
        {
            Ice.AsyncResult result;

            result = p.begin_op();
            p.end_op(result);
            try
            {
                p.end_op(result);
                test(false);
            }
            catch(System.ArgumentException)
            {
            }

            result = p.begin_op();
            try
            {
                p.end_opWithResult(result);
                test(false);
            }
            catch(System.ArgumentException)
            {
            }

            try
            {
                p.end_op(null);
                test(false);
            }
            catch(System.ArgumentException)
            {
            }
        }
        WriteLine("ok");

        Write("testing unexpected exceptions from callback... ");
        Flush();
        {
            Test.TestIntfPrx q = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy"));
            ThrowType[] throwEx = new ThrowType[]{ ThrowType.LocalException, ThrowType.UserException,
                                                   ThrowType.OtherException };

            for(int i = 0; i < 3; ++i)
            {
                Thrower cb = new Thrower(throwEx[i]);

                p.begin_op(cb.opAsync, null);
                cb.check();

                p.begin_op().whenCompleted(cb.op, null);
                cb.check();

                q.begin_op().whenCompleted(cb.op, cb.ex);
                cb.check();

                p.begin_op().whenCompleted(cb.noOp, cb.ex).whenSent(cb.sent);
                cb.check();

                q.begin_op().whenCompleted(cb.ex);
                cb.check();
            }
        }
        WriteLine("ok");

        Write("testing unexpected exceptions from callback with lambda... ");
        Flush();
        {
            Test.TestIntfPrx q = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy"));
            ThrowType[] throwEx = new ThrowType[]{ ThrowType.LocalException, ThrowType.UserException,
                                                   ThrowType.OtherException };

            for(int i = 0; i < 3; ++i)
            {
                Thrower cb = new Thrower(throwEx[i]);

                p.begin_op().whenCompleted(
                    () =>
                    {
                        cb.op();
                    }, null);
                cb.check();

                q.begin_op().whenCompleted(
                    () =>
                    {
                        cb.op();
                    },
                    (Ice.Exception ex) =>
                    {
                        cb.ex(ex);
                    });
                cb.check();

                p.begin_op().whenCompleted(
                    () =>
                    {
                        cb.noOp();
                    },
                    (Ice.Exception ex) =>
                    {
                        cb.ex(ex);
                    }
                ).whenSent(
                    (bool sentSynchronously) =>
                    {
                        cb.sent(sentSynchronously);
                    });
                cb.check();

                q.begin_op().whenCompleted(
                    (Ice.Exception ex) =>
                    {
                        cb.ex(ex);
                    });
                cb.check();
            }
        }
        WriteLine("ok");

        Write("testing batch requests with proxy... ");
        Flush();
        {
            test(p.ice_batchOneway().begin_ice_flushBatchRequests().sentSynchronously());

            Cookie cookie = new Cookie(5);

            {
                //
                // AsyncResult.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.opBatch();
                FlushCallback cb = new FlushCallback(cookie);
                Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(cb.completedAsync, cookie);
                r.whenSent(cb.sentAsync);
                cb.check();
                test(r.isSent());
                test(r.IsCompleted);
                test(p.waitForBatch(2));
            }

            if(p.ice_getConnection() != null)
            {
                //
                // AsyncResult exception.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.ice_getConnection().close(false);
                FlushExCallback cb = new FlushExCallback(cookie);
                Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(cb.completedAsync, cookie);
                r.whenSent(cb.sentAsync);
                cb.check();
                test(!r.isSent());
                test(r.IsCompleted);
                test(p.opBatchCount() == 0);
            }

            {
                //
                // Type-safe.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.opBatch();
                FlushCallback cb = new FlushCallback();
                Ice.AsyncResult r = b1.begin_ice_flushBatchRequests();
                r.whenCompleted(cb.exception);
                r.whenSent(cb.sent);
                cb.check();
                test(r.isSent());
                test(r.IsCompleted);
                test(p.waitForBatch(2));
            }

            if(p.ice_getConnection() != null)
            {
                //
                // Type-safe exception.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.ice_getConnection().close(false);
                FlushExCallback cb = new FlushExCallback();
                Ice.AsyncResult r = b1.begin_ice_flushBatchRequests();
                r.whenCompleted(cb.exception);
                r.whenSent(cb.sent);
                cb.check();
                test(!r.isSent());
                test(r.IsCompleted);
                test(p.opBatchCount() == 0);
            }
        }
        WriteLine("ok");

        Write("testing batch requests with proxy and lambda... ");
        Flush();
        {
            test(p.ice_batchOneway().begin_ice_flushBatchRequests().sentSynchronously());

            Cookie cookie = new Cookie(5);

            {
                //
                // AsyncResult.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.opBatch();
                FlushCallback cb = new FlushCallback(cookie);
                Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(
                    (Ice.AsyncResult result) =>
                    {
                        cb.completedAsync(result);
                    }, cookie);
                r.whenSent(
                    (Ice.AsyncResult result) =>
                    {
                        cb.sentAsync(result);
                    });
                cb.check();
                test(r.isSent());
                test(r.IsCompleted);
                test(p.waitForBatch(2));

                FlushCallback cb2 = new FlushCallback(cookie);
                Ice.AsyncResult r2 = b1.begin_ice_flushBatchRequests(
                    (Ice.AsyncResult result) =>
                    {
                        cb2.completedAsync(result);
                    }, cookie);
                r2.whenSent(
                    (Ice.AsyncResult result) =>
                    {
                        cb2.sentAsync(result);
                    });
                cb2.check();
                test(r2.isSent());
                test(r2.IsCompleted);
            }

            if(p.ice_getConnection() != null)
            {
                //
                // AsyncResult exception.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.ice_getConnection().close(false);
                FlushExCallback cb = new FlushExCallback(cookie);
                Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(
                    (Ice.AsyncResult result) =>
                    {
                        cb.completedAsync(result);
                    }, cookie);
                r.whenSent(
                    (Ice.AsyncResult result) =>
                    {
                        cb.sentAsync(result);
                    });
                cb.check();
                test(!r.isSent());
                test(r.IsCompleted);
                test(p.opBatchCount() == 0);
            }

            {
                //
                // Type-safe.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.opBatch();
                FlushCallback cb = new FlushCallback();
                Ice.AsyncResult r = b1.begin_ice_flushBatchRequests();
                r.whenCompleted(
                    (Ice.Exception ex) =>
                    {
                        cb.exception(ex);
                    });
                r.whenSent(
                    (bool sentSynchronously) =>
                    {
                        cb.sent(sentSynchronously);
                    });
                cb.check();
                test(r.isSent());
                test(r.IsCompleted);
                test(p.waitForBatch(2));
            }

            if(p.ice_getConnection() != null)
            {
                //
                // Type-safe exception.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.ice_getConnection().close(false);
                FlushExCallback cb = new FlushExCallback();
                Ice.AsyncResult r = b1.begin_ice_flushBatchRequests();
                r.whenCompleted(
                    (Ice.Exception ex) =>
                    {
                        cb.exception(ex);
                    });
                r.whenSent(
                    (bool sentSynchronously) =>
                    {
                        cb.sent(sentSynchronously);
                    });
                cb.check();
                test(!r.isSent());
                test(r.IsCompleted);
                test(p.opBatchCount() == 0);
            }
        }
        WriteLine("ok");

        if(p.ice_getConnection() != null)
        {
            Write("testing batch requests with connection... ");
            Flush();
            {
                Cookie cookie = new Cookie(5);

                {
                    //
                    // AsyncResult.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    b1.opBatch();
                    b1.opBatch();
                    FlushCallback cb = new FlushCallback(cookie);
                    Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(cb.completedAsync, cookie);
                    r.whenSent(cb.sentAsync);
                    cb.check();
                    test(r.isSent());
                    test(r.IsCompleted);
                    test(p.waitForBatch(2));
                }

                {
                    //
                    // AsyncResult exception.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    b1.opBatch();
                    b1.ice_getConnection().close(false);
                    FlushExCallback cb = new FlushExCallback(cookie);
                    Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(cb.completedAsync, cookie);
                    r.whenSent(cb.sentAsync);
                    cb.check();
                    test(!r.isSent());
                    test(r.IsCompleted);
                    test(p.opBatchCount() == 0);
                }

                {
                    //
                    // Type-safe.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    b1.opBatch();
                    b1.opBatch();
                    FlushCallback cb = new FlushCallback();
                    Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests();
                    r.whenCompleted(cb.exception);
                    r.whenSent(cb.sent);
                    cb.check();
                    test(r.isSent());
                    test(r.IsCompleted);
                    test(p.waitForBatch(2));
                }

                {
                    //
                    // Type-safe exception.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    b1.opBatch();
                    b1.ice_getConnection().close(false);
                    FlushExCallback cb = new FlushExCallback();
                    Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests();
                    r.whenCompleted(cb.exception);
                    r.whenSent(cb.sent);
                    cb.check();
                    test(!r.isSent());
                    test(r.IsCompleted);
                    test(p.opBatchCount() == 0);
                }
            }
            WriteLine("ok");
        }

        if(p.ice_getConnection() != null)
        {
            Write("testing batch requests with connection and lambda... ");
            Flush();
            {
                Cookie cookie = new Cookie(5);

                {
                    //
                    // AsyncResult.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    b1.opBatch();
                    b1.opBatch();
                    FlushCallback cb = new FlushCallback(cookie);
                    Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(
                        (Ice.AsyncResult result) =>
                        {
                            cb.completedAsync(result);
                        }, cookie);
                    r.whenSent(
                        (Ice.AsyncResult result) =>
                        {
                            cb.sentAsync(result);
                        });
                    cb.check();
                    test(r.isSent());
                    test(r.IsCompleted);
                    test(p.waitForBatch(2));
                }

                {
                    //
                    // AsyncResult exception.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    b1.opBatch();
                    b1.ice_getConnection().close(false);
                    FlushExCallback cb = new FlushExCallback(cookie);
                    Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(
                        (Ice.AsyncResult result) =>
                        {
                            cb.completedAsync(result);
                        }, cookie);
                    r.whenSent(
                        (Ice.AsyncResult result) =>
                        {
                            cb.sentAsync(result);
                        });
                    cb.check();
                    test(!r.isSent());
                    test(r.IsCompleted);
                    test(p.opBatchCount() == 0);
                }

                {
                    //
                    // Type-safe.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    b1.opBatch();
                    b1.opBatch();
                    FlushCallback cb = new FlushCallback();
                    Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests();
                    r.whenCompleted(
                        (Ice.Exception ex) =>
                        {
                            cb.exception(ex);
                        });
                    r.whenSent(
                        (bool sentSynchronously) =>
                        {
                            cb.sent(sentSynchronously);
                        });
                    cb.check();
                    test(r.isSent());
                    test(r.IsCompleted);
                    test(p.waitForBatch(2));
                }

                {
                    //
                    // Type-safe exception.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    b1.opBatch();
                    b1.ice_getConnection().close(false);
                    FlushExCallback cb = new FlushExCallback();
                    Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests();
                    r.whenCompleted(
                        (Ice.Exception ex) =>
                        {
                            cb.exception(ex);
                        });
                    r.whenSent(
                        (bool sentSynchronously) =>
                        {
                            cb.sent(sentSynchronously);
                        });
                    cb.check();
                    test(!r.isSent());
                    test(r.IsCompleted);
                    test(p.opBatchCount() == 0);
                }
            }
            WriteLine("ok");

            Write("testing batch requests with communicator... ");
            Flush();
            {
                Cookie cookie = new Cookie(5);

                {
                    //
                    // AsyncResult - 1 connection.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    b1.opBatch();
                    b1.opBatch();
                    FlushCallback cb = new FlushCallback(cookie);
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie);
                    r.whenSent(cb.sentAsync);
                    cb.check();
                    test(r.isSent());
                    test(r.IsCompleted);
                    test(p.waitForBatch(2));
                }

                {
                    //
                    // AsyncResult exception - 1 connection.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    b1.opBatch();
                    b1.ice_getConnection().close(false);
                    FlushCallback cb = new FlushCallback(cookie);
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie);
                    r.whenSent(cb.sentAsync);
                    cb.check();
                    test(r.isSent()); // Exceptions are ignored!
                    test(r.IsCompleted);
                    test(p.opBatchCount() == 0);
                }

                {
                    //
                    // AsyncResult - 2 connections.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                    b2.ice_getConnection(); // Ensure connection is established.
                    b1.opBatch();
                    b1.opBatch();
                    b2.opBatch();
                    b2.opBatch();
                    FlushCallback cb = new FlushCallback(cookie);
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie);
                    r.whenSent(cb.sentAsync);
                    cb.check();
                    test(r.isSent());
                    test(r.IsCompleted);
                    test(p.waitForBatch(4));
                }

                {
                    //
                    // AsyncResult exception - 2 connections - 1 failure.
                    //
                    // All connections should be flushed even if there are failures on some connections.
                    // Exceptions should not be reported.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                    b2.ice_getConnection(); // Ensure connection is established.
                    b1.opBatch();
                    b2.opBatch();
                    b1.ice_getConnection().close(false);
                    FlushCallback cb = new FlushCallback(cookie);
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie);
                    r.whenSent(cb.sentAsync);
                    cb.check();
                    test(r.isSent()); // Exceptions are ignored!
                    test(r.IsCompleted);
                    test(p.waitForBatch(1));
                }

                {
                    //
                    // AsyncResult exception - 2 connections - 2 failures.
                    //
                    // The sent callback should be invoked even if all connections fail.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                    b2.ice_getConnection(); // Ensure connection is established.
                    b1.opBatch();
                    b2.opBatch();
                    b1.ice_getConnection().close(false);
                    b2.ice_getConnection().close(false);
                    FlushCallback cb = new FlushCallback(cookie);
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie);
                    r.whenSent(cb.sentAsync);
                    cb.check();
                    test(r.isSent()); // Exceptions are ignored!
                    test(r.IsCompleted);
                    test(p.opBatchCount() == 0);
                }

                {
                    //
                    // Type-safe - 1 connection.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    b1.opBatch();
                    b1.opBatch();
                    FlushCallback cb = new FlushCallback();
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests();
                    r.whenCompleted(cb.exception);
                    r.whenSent(cb.sent);
                    cb.check();
                    test(r.isSent());
                    test(r.IsCompleted);
                    test(p.waitForBatch(2));
                }

                {
                    //
                    // Type-safe exception - 1 connection.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    b1.opBatch();
                    b1.ice_getConnection().close(false);
                    FlushCallback cb = new FlushCallback();
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests();
                    r.whenCompleted(cb.exception);
                    r.whenSent(cb.sent);
                    cb.check();
                    test(r.isSent()); // Exceptions are ignored!
                    test(r.IsCompleted);
                    test(p.opBatchCount() == 0);
                }

                {
                    //
                    // 2 connections.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                    b2.ice_getConnection(); // Ensure connection is established.
                    b1.opBatch();
                    b1.opBatch();
                    b2.opBatch();
                    b2.opBatch();
                    FlushCallback cb = new FlushCallback();
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests();
                    r.whenCompleted(cb.exception);
                    r.whenSent(cb.sent);
                    cb.check();
                    test(r.isSent());
                    test(r.IsCompleted);
                    test(p.waitForBatch(4));
                }

                {
                    //
                    // Exception - 2 connections - 1 failure.
                    //
                    // All connections should be flushed even if there are failures on some connections.
                    // Exceptions should not be reported.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                    b2.ice_getConnection(); // Ensure connection is established.
                    b1.opBatch();
                    b2.opBatch();
                    b1.ice_getConnection().close(false);
                    FlushCallback cb = new FlushCallback();
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests();
                    r.whenCompleted(cb.exception);
                    r.whenSent(cb.sent);
                    cb.check();
                    test(r.isSent()); // Exceptions are ignored!
                    test(r.IsCompleted);
                    test(p.waitForBatch(1));
                }

                {
                    //
                    // Exception - 2 connections - 2 failures.
                    //
                    // The sent callback should be invoked even if all connections fail.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                    b2.ice_getConnection(); // Ensure connection is established.
                    b1.opBatch();
                    b2.opBatch();
                    b1.ice_getConnection().close(false);
                    b2.ice_getConnection().close(false);
                    FlushCallback cb = new FlushCallback();
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests();
                    r.whenCompleted(cb.exception);
                    r.whenSent(cb.sent);
                    cb.check();
                    test(r.isSent()); // Exceptions are ignored!
                    test(r.IsCompleted);
                    test(p.opBatchCount() == 0);
                }
            }
            WriteLine("ok");

            Write("testing batch requests with communicator with lambda... ");
            Flush();
            {
                Cookie cookie = new Cookie(5);

                {
                    //
                    // AsyncResult - 1 connection.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    b1.opBatch();
                    b1.opBatch();
                    FlushCallback cb = new FlushCallback(cookie);
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests(
                        (Ice.AsyncResult result) =>
                        {
                            cb.completedAsync(result);
                        }, cookie);
                    r.whenSent(
                        (Ice.AsyncResult result) =>
                        {
                            cb.sentAsync(result);
                        });
                    cb.check();
                    test(r.isSent());
                    test(r.IsCompleted);
                    test(p.waitForBatch(2));
                }

                {
                    //
                    // AsyncResult exception - 1 connection.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    b1.opBatch();
                    b1.ice_getConnection().close(false);
                    FlushCallback cb = new FlushCallback(cookie);
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests(
                        (Ice.AsyncResult result) =>
                        {
                            cb.completedAsync(result);
                        }, cookie);
                    r.whenSent(
                        (Ice.AsyncResult result) =>
                        {
                            cb.sentAsync(result);
                        });
                    cb.check();
                    test(r.isSent()); // Exceptions are ignored!
                    test(r.IsCompleted);
                    test(p.opBatchCount() == 0);
                }

                {
                    //
                    // AsyncResult - 2 connections.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                    b2.ice_getConnection(); // Ensure connection is established.
                    b1.opBatch();
                    b1.opBatch();
                    b2.opBatch();
                    b2.opBatch();
                    FlushCallback cb = new FlushCallback(cookie);
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests(
                        (Ice.AsyncResult result) =>
                        {
                            cb.completedAsync(result);
                        }, cookie);
                    r.whenSent(
                        (Ice.AsyncResult result) =>
                        {
                            cb.sentAsync(result);
                        });
                    cb.check();
                    test(r.isSent());
                    test(r.IsCompleted);
                    test(p.waitForBatch(4));
                }

                {
                    //
                    // AsyncResult exception - 2 connections - 1 failure.
                    //
                    // All connections should be flushed even if there are failures on some connections.
                    // Exceptions should not be reported.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                    b2.ice_getConnection(); // Ensure connection is established.
                    b1.opBatch();
                    b2.opBatch();
                    b1.ice_getConnection().close(false);
                    FlushCallback cb = new FlushCallback(cookie);
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests(
                        (Ice.AsyncResult result) =>
                        {
                            cb.completedAsync(result);
                        }, cookie);
                    r.whenSent(
                        (Ice.AsyncResult result) =>
                        {
                            cb.sentAsync(result);
                        });
                    cb.check();
                    test(r.isSent()); // Exceptions are ignored!
                    test(r.IsCompleted);
                    test(p.waitForBatch(1));
                }

                {
                    //
                    // AsyncResult exception - 2 connections - 2 failures.
                    //
                    // The sent callback should be invoked even if all connections fail.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                    b2.ice_getConnection(); // Ensure connection is established.
                    b1.opBatch();
                    b2.opBatch();
                    b1.ice_getConnection().close(false);
                    b2.ice_getConnection().close(false);
                    FlushCallback cb = new FlushCallback(cookie);
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests(
                        (Ice.AsyncResult result) =>
                        {
                            cb.completedAsync(result);
                        }, cookie);
                    r.whenSent(
                        (Ice.AsyncResult result) =>
                        {
                            cb.sentAsync(result);
                        });
                    cb.check();
                    test(r.isSent()); // Exceptions are ignored!
                    test(r.IsCompleted);
                    test(p.opBatchCount() == 0);
                }

                {
                    //
                    // Type-safe - 1 connection.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    b1.opBatch();
                    b1.opBatch();
                    FlushCallback cb = new FlushCallback();
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests();
                    r.whenCompleted(
                        (Ice.Exception ex) =>
                        {
                            cb.exception(ex);
                        });
                    r.whenSent(
                        (bool sentSynchronously) =>
                        {
                            cb.sent(sentSynchronously);
                        });
                    cb.check();
                    test(r.isSent());
                    test(r.IsCompleted);
                    test(p.waitForBatch(2));
                }

                {
                    //
                    // Type-safe exception - 1 connection.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    b1.opBatch();
                    b1.ice_getConnection().close(false);
                    FlushCallback cb = new FlushCallback();
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests();
                    r.whenCompleted(
                        (Ice.Exception ex) =>
                        {
                            cb.exception(ex);
                        });
                    r.whenSent(
                        (bool sentSynchronously) =>
                        {
                            cb.sent(sentSynchronously);
                        });
                    cb.check();
                    test(r.isSent()); // Exceptions are ignored!
                    test(r.IsCompleted);
                    test(p.opBatchCount() == 0);
                }

                {
                    //
                    // 2 connections.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                    b2.ice_getConnection(); // Ensure connection is established.
                    b1.opBatch();
                    b1.opBatch();
                    b2.opBatch();
                    b2.opBatch();
                    FlushCallback cb = new FlushCallback();
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests();
                    r.whenCompleted(
                        (Ice.Exception ex) =>
                        {
                            cb.exception(ex);
                        });
                    r.whenSent(
                        (bool sentSynchronously) =>
                        {
                            cb.sent(sentSynchronously);
                        });
                    cb.check();
                    test(r.isSent());
                    test(r.IsCompleted);
                    test(p.waitForBatch(4));
                }

                {
                    //
                    // Exception - 2 connections - 1 failure.
                    //
                    // All connections should be flushed even if there are failures on some connections.
                    // Exceptions should not be reported.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                    b2.ice_getConnection(); // Ensure connection is established.
                    b1.opBatch();
                    b2.opBatch();
                    b1.ice_getConnection().close(false);
                    FlushCallback cb = new FlushCallback();
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests();
                    r.whenCompleted(
                        (Ice.Exception ex) =>
                        {
                            cb.exception(ex);
                        });
                    r.whenSent(
                        (bool sentSynchronously) =>
                        {
                            cb.sent(sentSynchronously);
                        });
                    cb.check();
                    test(r.isSent()); // Exceptions are ignored!
                    test(r.IsCompleted);
                    test(p.waitForBatch(1));
                }

                {
                    //
                    // Exception - 2 connections - 2 failures.
                    //
                    // The sent callback should be invoked even if all connections fail.
                    //
                    test(p.opBatchCount() == 0);
                    TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                    TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                    b2.ice_getConnection(); // Ensure connection is established.
                    b1.opBatch();
                    b2.opBatch();
                    b1.ice_getConnection().close(false);
                    b2.ice_getConnection().close(false);
                    FlushCallback cb = new FlushCallback();
                    Ice.AsyncResult r = communicator.begin_flushBatchRequests();
                    r.whenCompleted(
                        (Ice.Exception ex) =>
                        {
                            cb.exception(ex);
                        });
                    r.whenSent(
                        (bool sentSynchronously) =>
                        {
                            cb.sent(sentSynchronously);
                        });
                    cb.check();
                    test(r.isSent()); // Exceptions are ignored!
                    test(r.IsCompleted);
                    test(p.opBatchCount() == 0);
                }
            }
            WriteLine("ok");
        }

        Write("testing AsyncResult operations... ");
        Flush();
        {
            {
                testController.holdAdapter();
                Ice.AsyncResult r1;
                Ice.AsyncResult r2;
                try
                {
                    r1 = p.begin_op();
                    byte[] seq = new byte[10024];
                    (new System.Random()).NextBytes(seq);
                    while((r2 = p.begin_opWithPayload(seq)).sentSynchronously());

                    if(p.ice_getConnection() != null)
                    {
                        test(r1.sentSynchronously() && r1.isSent() && !r1.isCompleted_() ||
                             !r1.sentSynchronously() && !r1.isCompleted_());

                        test(!r2.sentSynchronously() && !r2.isCompleted_());

                        test(!r1.IsCompleted && !r1.CompletedSynchronously);
                        test(!r2.IsCompleted && !r2.CompletedSynchronously);
                    }
                }
                finally
                {
                    testController.resumeAdapter();
                }

                WaitHandle w1 = r1.AsyncWaitHandle;
                WaitHandle w2 = r2.AsyncWaitHandle;

                r1.waitForSent();
                test(r1.isSent());

                r2.waitForSent();
                test(r2.isSent());

                r1.waitForCompleted();
                test(r1.isCompleted_());
                w1.WaitOne();

                r2.waitForCompleted();
                test(r2.isCompleted_());
                w2.WaitOne();

                test(r1.getOperation().Equals("op"));
                test(r2.getOperation().Equals("opWithPayload"));
            }

            {
                Ice.AsyncResult r;

                //
                // Twoway
                //
                r = p.begin_ice_ping();
                test(r.getOperation().Equals("ice_ping"));
                test(r.getConnection() == null); // Expected
                test(r.getCommunicator() == communicator);
                test(r.getProxy() == p);
                p.end_ice_ping(r);

                Test.TestIntfPrx p2;

                //
                // Oneway
                //
                p2 = p.ice_oneway() as Test.TestIntfPrx;
                r = p2.begin_ice_ping();
                test(r.getOperation().Equals("ice_ping"));
                test(r.getConnection() == null); // Expected
                test(r.getCommunicator() == communicator);
                test(r.getProxy() == p2);

                //
                // Batch request via proxy
                //
                p2 = p.ice_batchOneway() as Test.TestIntfPrx;
                p2.ice_ping();
                r = p2.begin_ice_flushBatchRequests();
                test(r.getConnection() == null); // Expected
                test(r.getCommunicator() == communicator);
                test(r.getProxy() == p2);
                p2.end_ice_flushBatchRequests(r);

                if(p.ice_getConnection() != null)
                {
                    //
                    // Batch request via connection
                    //
                    Ice.Connection con = p.ice_getConnection();
                    p2 = p.ice_batchOneway() as Test.TestIntfPrx;
                    p2.ice_ping();
                    r = con.begin_flushBatchRequests();
                    test(r.getConnection() == con);
                    test(r.getCommunicator() == communicator);
                    test(r.getProxy() == null); // Expected
                    con.end_flushBatchRequests(r);

                    //
                    // Batch request via communicator
                    //
                    p2 = p.ice_batchOneway() as Test.TestIntfPrx;
                    p2.ice_ping();
                    r = communicator.begin_flushBatchRequests();
                    test(r.getConnection() == null); // Expected
                    test(r.getCommunicator() == communicator);
                    test(r.getProxy() == null); // Expected
                    communicator.end_flushBatchRequests(r);
                }
            }

            if(p.ice_getConnection() != null)
            {
                Ice.AsyncResult r1 = null;
                Ice.AsyncResult r2 = null;
                testController.holdAdapter();
                try
                {
                    Ice.AsyncResult r = null;
                    byte[] seq = new byte[10024];
                    for(int i = 0; i < 200; ++i) // 2MB
                    {
                        r = p.begin_opWithPayload(seq);
                    }

                    test(!r.isSent());

                    r1 = p.begin_ice_ping();
                    r2 = p.begin_ice_id();
                    r1.cancel();
                    r2.cancel();
                    try
                    {
                        p.end_ice_ping(r1);
                        test(false);
                    }
                    catch(Ice.InvocationCanceledException)
                    {
                    }
                    try
                    {
                        p.end_ice_id(r2);
                        test(false);
                    }
                    catch(Ice.InvocationCanceledException)
                    {
                    }

                }
                finally
                {
                    testController.resumeAdapter();
                    p.ice_ping();
                    test(!r1.isSent() && r1.isCompleted_());
                    test(!r2.isSent() && r2.isCompleted_());
                }


                testController.holdAdapter();
                try
                {
                    r1 = p.begin_op();
                    r2 = p.begin_ice_id();
                    r1.waitForSent();
                    r2.waitForSent();
                    r1.cancel();
                    r2.cancel();
                    try
                    {
                        p.end_op(r1);
                        test(false);
                    }
                    catch(Ice.InvocationCanceledException)
                    {
                    }
                    try
                    {
                        p.end_ice_id(r2);
                        test(false);
                    }
                    catch(Ice.InvocationCanceledException)
                    {
                    }
                }
                finally
                {
                    testController.resumeAdapter();
                }
            }
        }
        WriteLine("ok");

        if(p.ice_getConnection() != null)
        {
            Write("testing close connection with sending queue... ");
            Flush();
            {
                byte[] seq = new byte[1024 * 10];

                //
                // Send multiple opWithPayload, followed by a close and followed by multiple opWithPaylod.
                // The goal is to make sure that none of the opWithPayload fail even if the server closes
                // the connection gracefully in between.
                //
                int maxQueue = 2;
                bool done = false;
                while(!done && maxQueue < 50)
                {
                    done = true;
                    p.ice_ping();
                    List<Ice.AsyncResult> results = new List<Ice.AsyncResult>();
                    for(int i = 0; i < maxQueue; ++i)
                    {
                        results.Add(p.begin_opWithPayload(seq));
                    }
                    if(!p.begin_close(false).isSent())
                    {
                        for(int i = 0; i < maxQueue; i++)
                        {
                            Ice.AsyncResult r = p.begin_opWithPayload(seq);
                            results.Add(r);
                            if(r.isSent())
                            {
                                done = false;
                                maxQueue *= 2;
                                break;
                            }
                        }
                    }
                    else
                    {
                        maxQueue *= 2;
                        done = false;
                    }
                    foreach(Ice.AsyncResult q in results)
                    {
                        q.waitForCompleted();
                        try
                        {
                            q.throwLocalException();
                        }
                        catch(Ice.LocalException)
                        {
                            test(false);
                        }
                    }
                }
            }
            WriteLine("ok");
        }

        p.shutdown();
    }
 public unsafe OverlappedIOCallback(WaitCallback callback, ExceptionCallback exceptionCallback)
 {
     Overlapped overlapped = new Overlapped(0, 0, IntPtr.Zero, null);
     this.nativeOverlapped = overlapped.UnsafePack(new IOCompletionThunk(this.IOCallback, exceptionCallback).ThunkFrame, null);
     this.callback = callback;
 }
Beispiel #43
0
 public void GetServerMethods(GetServerMethodsCallback callback = null, ExceptionCallback ExCal = null)
 {
     DSRESTCommand cmd = getConnection().CreateCommand();
     cmd.setRequestType(DSHTTPRequestType.GET);
     cmd.setText("DSAdmin.GetServerMethods");
     cmd.prepare(get_DSAdmin_GetServerMethods_Metadata());
     GetServerMethodsDelegate GetServerMethodsDel = () => {
       if (callback != null)
       {
     callback.DynamicInvoke((TDBXReader)cmd.getParameter(0).getValue().GetAsTable());
       }
     };
     getConnection().execute(cmd, this, GetServerMethodsDel, ExCal);
 }
Beispiel #44
0
 public void DescribeMethod(String ServerMethodName, DescribeMethodCallback callback = null, ExceptionCallback ExCal = null)
 {
     DSRESTCommand cmd = getConnection().CreateCommand();
     cmd.setRequestType(DSHTTPRequestType.GET);
     cmd.setText("DSAdmin.DescribeMethod");
     cmd.prepare(get_DSAdmin_DescribeMethod_Metadata());
     DescribeMethodDelegate DescribeMethodDel = () => {
       if (callback != null)
       {
     callback.DynamicInvoke((TJSONObject)cmd.getParameter(1).getValue().GetAsJSONValue());
       }
     };
     cmd.getParameter(0).getValue().SetAsString(ServerMethodName);
     getConnection().execute(cmd, this, DescribeMethodDel, ExCal);
 }
 public ManagedCallback(WaitCallback callback, ExceptionCallback exceptionCallback, object state)
 {
     this.callback = callback;
     this.exceptionCallback = exceptionCallback;
     this.state = state;
 }
Beispiel #46
0
        public Form1()
        {
            bVista = (Environment.OSVersion.Version.Major == 6);

            // Required for Windows Form Designer support
            InitializeComponent();

            // Late setup of the CPU monitor - (Bails-out if in Vista)
            InitializePeformanceMonitor();

            // Hide the CPU load monitor if running in Windows Vista
            // Detecting the CPU load is a security violation in Vista
            CPULoadBox.Visible = !bVista;

            // Setup the callback routine for updating the UI
            updateUI = new UpdateUICallback(StatusUpdate);

            // Setup the callback routine for NullReference exception handling
            handleException = new ExceptionCallback(ThreadException);

            // Create the list of USB devices attached to the CyUSB3.sys driver.
            usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);

            //Assign event handlers for device attachment and device removal.
            usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached);
            usbDevices.DeviceRemoved += new EventHandler(usbDevices_DeviceRemoved);

            //Set and search the device with VID-PID 04b4-1003 and if found, selects the end point
            SetDevice();
        }
Beispiel #47
0
 public void ConsumeClientChannelTimeout(String ChannelName, String ClientManagerId, String CallbackId, String ChannelNames, String SecurityToken, int Timeout, TJSONValue ResponseData, ConsumeClientChannelTimeoutCallback callback = null, ExceptionCallback ExCal = null)
 {
     DSRESTCommand cmd = getConnection().CreateCommand();
     cmd.setRequestType(DSHTTPRequestType.POST);
     cmd.setText("DSAdmin.ConsumeClientChannelTimeout");
     cmd.prepare(get_DSAdmin_ConsumeClientChannelTimeout_Metadata());
     ConsumeClientChannelTimeoutDelegate ConsumeClientChannelTimeoutDel = () => {
       if (callback != null)
       {
     callback.DynamicInvoke((TJSONValue)cmd.getParameter(7).getValue().GetAsJSONValue());
       }
     };
     cmd.getParameter(0).getValue().SetAsString(ChannelName);
     cmd.getParameter(1).getValue().SetAsString(ClientManagerId);
     cmd.getParameter(2).getValue().SetAsString(CallbackId);
     cmd.getParameter(3).getValue().SetAsString(ChannelNames);
     cmd.getParameter(4).getValue().SetAsString(SecurityToken);
     cmd.getParameter(5).getValue().SetAsInt32(Timeout);
     cmd.getParameter(6).getValue().SetAsJSONValue(ResponseData);
     getConnection().execute(cmd, this, ConsumeClientChannelTimeoutDel, ExCal);
 }
Beispiel #48
0
 public void GetPlatformName(GetPlatformNameCallback callback = null, ExceptionCallback ExCal = null)
 {
     DSRESTCommand cmd = getConnection().CreateCommand();
     cmd.setRequestType(DSHTTPRequestType.GET);
     cmd.setText("DSAdmin.GetPlatformName");
     cmd.prepare(get_DSAdmin_GetPlatformName_Metadata());
     GetPlatformNameDelegate GetPlatformNameDel = () => {
       if (callback != null)
       {
     callback.DynamicInvoke(cmd.getParameter(0).getValue().GetAsString());
       }
     };
     getConnection().execute(cmd, this, GetPlatformNameDel, ExCal);
 }
Beispiel #49
0
 public void NotifyObject(String ClientId, String CallbackId, TJSONObject Msg, NotifyObjectCallback callback = null, ExceptionCallback ExCal = null)
 {
     DSRESTCommand cmd = getConnection().CreateCommand();
     cmd.setRequestType(DSHTTPRequestType.POST);
     cmd.setText("DSAdmin.NotifyObject");
     cmd.prepare(get_DSAdmin_NotifyObject_Metadata());
     NotifyObjectDelegate NotifyObjectDel = () => {
       if (callback != null)
       {
     NotifyObjectReturns ret = new NotifyObjectReturns();
     ret.Response = (TJSONObject)cmd.getParameter(3).getValue().GetAsJSONValue();
     ret.returnValue = cmd.getParameter(4).getValue().GetAsBoolean();
     callback.DynamicInvoke(ret);
       }
     };
     cmd.getParameter(0).getValue().SetAsString(ClientId);
     cmd.getParameter(1).getValue().SetAsString(CallbackId);
     cmd.getParameter(2).getValue().SetAsJSONValue(Msg);
     getConnection().execute(cmd, this, NotifyObjectDel, ExCal);
 }
Beispiel #50
0
 public void DropServerClasses(TDBXReader ClassReader, DropServerClassesCallback callback = null, ExceptionCallback ExCal = null)
 {
     DSRESTCommand cmd = getConnection().CreateCommand();
     cmd.setRequestType(DSHTTPRequestType.POST);
     cmd.setText("DSAdmin.DropServerClasses");
     cmd.prepare(get_DSAdmin_DropServerClasses_Metadata());
     DropServerClassesDelegate DropServerClassesDel = () => {
       if (callback != null)
       {
     callback.DynamicInvoke();
       }
     };
     cmd.getParameter(0).getValue().SetAsTable(ClassReader);
     getConnection().execute(cmd, this, DropServerClassesDel, ExCal);
 }
Beispiel #51
0
 public void ListMethods(String ClassName, ListMethodsCallback callback = null, ExceptionCallback ExCal = null)
 {
     DSRESTCommand cmd = getConnection().CreateCommand();
     cmd.setRequestType(DSHTTPRequestType.GET);
     cmd.setText("DSAdmin.ListMethods");
     cmd.prepare(get_DSAdmin_ListMethods_Metadata());
     ListMethodsDelegate ListMethodsDel = () => {
       if (callback != null)
       {
     callback.DynamicInvoke((TJSONArray)cmd.getParameter(1).getValue().GetAsJSONValue());
       }
     };
     cmd.getParameter(0).getValue().SetAsString(ClassName);
     getConnection().execute(cmd, this, ListMethodsDel, ExCal);
 }
            public IOCompletionThunk(IOCompletionCallback callback, ExceptionCallback exceptionCallback)
            {
                if (callback == null) throw new ArgumentNullException("callback");
                if (exceptionCallback == null) throw new ArgumentNullException("exceptionCallback");

                this.callback = callback;
                this.exceptionCallback = exceptionCallback;
            }
Beispiel #53
0
    public static void allTests(Ice.Communicator communicator)
    {
        string sref = "test:default -p 12010";
        Ice.ObjectPrx obj = communicator.stringToProxy(sref);
        test(obj != null);

        Test.TestIntfPrx p = Test.TestIntfPrxHelper.uncheckedCast(obj);

        sref = "testController:tcp -p 12011";
        obj = communicator.stringToProxy(sref);
        test(obj != null);

        Test.TestIntfControllerPrx testController = Test.TestIntfControllerPrxHelper.uncheckedCast(obj);

        Console.Out.Write("testing begin/end invocation... ");
        Console.Out.Flush();
        {
            Ice.AsyncResult result;
            Dictionary<string, string> ctx = new Dictionary<string, string>();

            result = p.begin_ice_isA("::Test::TestIntf");
            test(p.end_ice_isA(result));
            result = p.begin_ice_isA("::Test::TestIntf", ctx);
            test(p.end_ice_isA(result));

            result = p.begin_ice_ping();
            p.end_ice_ping(result);
            result = p.begin_ice_ping(ctx);
            p.end_ice_ping(result);

            result = p.begin_ice_id();
            test(p.end_ice_id(result).Equals("::Test::TestIntf"));
            result = p.begin_ice_id(ctx);
            test(p.end_ice_id(result).Equals("::Test::TestIntf"));

            result = p.begin_ice_ids();
            test(p.end_ice_ids(result).Length == 2);
            result = p.begin_ice_ids(ctx);
            test(p.end_ice_ids(result).Length == 2);

            result = p.begin_op();
            p.end_op(result);
            result = p.begin_op(ctx);
            p.end_op(result);

            result = p.begin_opWithResult();
            test(p.end_opWithResult(result) == 15);
            result = p.begin_opWithResult(ctx);
            test(p.end_opWithResult(result) == 15);

            result = p.begin_opWithUE();
            try
            {
                p.end_opWithUE(result);
                test(false);
            }
            catch(Test.TestIntfException)
            {
            }
            result = p.begin_opWithUE(ctx);
            try
            {
                p.end_opWithUE(result);
                test(false);
            }
            catch(Test.TestIntfException)
            {
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing async callback... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            Dictionary<string, string> ctx = new Dictionary<string, string>();
            Cookie cookie = new Cookie(5);
            AsyncCallback cbWC = new AsyncCallback(cookie);

            p.begin_ice_isA("::Test::TestIntf", cb.isA, null);
            cb.check();
            p.begin_ice_isA("::Test::TestIntf", cbWC.isA, cookie);
            cbWC.check();
            p.begin_ice_isA("::Test::TestIntf", ctx, cb.isA, null);
            cb.check();
            p.begin_ice_isA("::Test::TestIntf", ctx, cbWC.isA, cookie);
            cbWC.check();

            p.begin_ice_ping(cb.ping, null);
            cb.check();
            p.begin_ice_ping(cbWC.ping, cookie);
            cbWC.check();
            p.begin_ice_ping(ctx, cb.ping, null);
            cb.check();
            p.begin_ice_ping(ctx, cbWC.ping, cookie);
            cbWC.check();

            p.begin_ice_id(cb.id, null);
            cb.check();
            p.begin_ice_id(cbWC.id, cookie);
            cbWC.check();
            p.begin_ice_id(ctx, cb.id, null);
            cb.check();
            p.begin_ice_id(ctx, cbWC.id, cookie);
            cbWC.check();

            p.begin_ice_ids(cb.ids, null);
            cb.check();
            p.begin_ice_ids(cbWC.ids, cookie);
            cbWC.check();
            p.begin_ice_ids(ctx, cb.ids, null);
            cb.check();
            p.begin_ice_ids(ctx, cbWC.ids, cookie);
            cbWC.check();

            p.begin_op(cb.op, null);
            cb.check();
            p.begin_op(cbWC.op, cookie);
            cbWC.check();
            p.begin_op(ctx, cb.op, null);
            cb.check();
            p.begin_op(ctx, cbWC.op, cookie);
            cbWC.check();

            p.begin_opWithResult(cb.opWithResult, null);
            cb.check();
            p.begin_opWithResult(cbWC.opWithResult, cookie);
            cbWC.check();
            p.begin_opWithResult(ctx, cb.opWithResult, null);
            cb.check();
            p.begin_opWithResult(ctx, cbWC.opWithResult, cookie);
            cbWC.check();

            p.begin_opWithUE(cb.opWithUE, null);
            cb.check();
            p.begin_opWithUE(cbWC.opWithUE, cookie);
            cbWC.check();
            p.begin_opWithUE(ctx, cb.opWithUE, null);
            cb.check();
            p.begin_opWithUE(ctx, cbWC.opWithUE, cookie);
            cbWC.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing response callback... ");
        Console.Out.Flush();
        {
            ResponseCallback cb = new ResponseCallback();
            Dictionary<string, string> ctx = new Dictionary<string, string>();

            p.begin_ice_isA("::Test::TestIntf").whenCompleted(cb.isA, null);
            cb.check();
            p.begin_ice_isA("::Test::TestIntf", ctx).whenCompleted(cb.isA, null);
            cb.check();

            p.begin_ice_ping().whenCompleted(cb.ping, null);
            cb.check();
            p.begin_ice_ping(ctx).whenCompleted(cb.ping, null);
            cb.check();

            p.begin_ice_id().whenCompleted(cb.id, null);
            cb.check();
            p.begin_ice_id(ctx).whenCompleted(cb.id, null);
            cb.check();

            p.begin_ice_ids().whenCompleted(cb.ids, null);
            cb.check();
            p.begin_ice_ids(ctx).whenCompleted(cb.ids, null);
            cb.check();

            p.begin_op().whenCompleted(cb.op, null);
            cb.check();
            p.begin_op(ctx).whenCompleted(cb.op, null);
            cb.check();

            p.begin_opWithResult().whenCompleted(cb.opWithResult, null);
            cb.check();
            p.begin_opWithResult(ctx).whenCompleted(cb.opWithResult, null);
            cb.check();

            p.begin_opWithUE().whenCompleted(cb.op, cb.opWithUE);
            cb.check();
            p.begin_opWithUE(ctx).whenCompleted(cb.op, cb.opWithUE);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing local exceptions... ");
        Console.Out.Flush();
        {
            Test.TestIntfPrx indirect = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy"));
            Ice.AsyncResult r;

            r = indirect.begin_op();
            try
            {
                indirect.end_op(r);
                test(false);
            }
            catch(Ice.NoEndpointException)
            {
            }

            try
            {
                r = ((Test.TestIntfPrx)p.ice_oneway()).begin_opWithResult();
                test(false);
            }
            catch(System.ArgumentException)
            {
            }

            //
            // Check that CommunicatorDestroyedException is raised directly.
            //
            Ice.InitializationData initData = new Ice.InitializationData();
            initData.properties = communicator.getProperties().ice_clone_();
            Ice.Communicator ic = Ice.Util.initialize(initData);
            Ice.ObjectPrx o = ic.stringToProxy(p.ToString());
            Test.TestIntfPrx p2 = Test.TestIntfPrxHelper.checkedCast(o);
            ic.destroy();

            try
            {
                p2.begin_op();
                test(false);
            }
            catch(Ice.CommunicatorDestroyedException)
            {
                // Expected.
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing local exceptions with async callback... ");
        Console.Out.Flush();
        {
            Test.TestIntfPrx i = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy"));
            AsyncCallback cb = new AsyncCallback();
            Cookie cookie = new Cookie(5);
            AsyncCallback cbWC = new AsyncCallback(cookie);

            i.begin_ice_isA("::Test::TestIntf", cb.isAEx, null);
            cb.check();
            i.begin_ice_isA("::Test::TestIntf", cbWC.isAEx, cookie);
            cbWC.check();

            i.begin_ice_ping(cb.pingEx, null);
            cb.check();
            i.begin_ice_ping(cbWC.pingEx, cookie);
            cbWC.check();

            i.begin_ice_id(cb.idEx, null);
            cb.check();
            i.begin_ice_id(cbWC.idEx, cookie);
            cbWC.check();

            i.begin_ice_ids(cb.idsEx, null);
            cb.check();
            i.begin_ice_ids(cbWC.idsEx, cookie);
            cbWC.check();

            i.begin_op(cb.opEx, null);
            cb.check();
            i.begin_op(cbWC.opEx, cookie);
            cbWC.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing local exceptions with response callback... ");
        Console.Out.Flush();
        {
            Test.TestIntfPrx i = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy"));
            ExceptionCallback cb = new ExceptionCallback();

            i.begin_ice_isA("::Test::TestIntf").whenCompleted(cb.isA, cb.ex);
            cb.check();

            i.begin_ice_ping().whenCompleted(cb.ping, cb.ex);
            cb.check();

            i.begin_ice_id().whenCompleted(cb.id, cb.ex);
            cb.check();

            i.begin_ice_ids().whenCompleted(cb.ids, cb.ex);
            cb.check();

            i.begin_op().whenCompleted(cb.op, cb.ex);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing exception callback... ");
        Console.Out.Flush();
        {
            Test.TestIntfPrx i = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy"));
            ExceptionCallback cb = new ExceptionCallback();

            i.begin_ice_isA("::Test::TestIntf").whenCompleted(cb.ex);
            cb.check();

            i.begin_op().whenCompleted(cb.ex);
            cb.check();

            i.begin_opWithResult().whenCompleted(cb.ex);
            cb.check();

            i.begin_opWithUE().whenCompleted(cb.ex);
            cb.check();

            // Ensures no exception is called when response is received
            p.begin_ice_isA("::Test::TestIntf").whenCompleted(cb.noEx);
            p.begin_op().whenCompleted(cb.noEx);
            p.begin_opWithResult().whenCompleted(cb.noEx);

            // If response is a user exception, it should be received.
            p.begin_opWithUE().whenCompleted(cb.opWithUE);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing sent callback... ");
        Console.Out.Flush();
        {
            SentCallback cb = new SentCallback();

            p.begin_ice_isA("").whenCompleted(cb.isA, cb.ex).whenSent(cb.sent);
            cb.check();

            p.begin_ice_ping().whenCompleted(cb.ping, cb.ex).whenSent(cb.sent);
            cb.check();

            p.begin_ice_id().whenCompleted(cb.id, cb.ex).whenSent(cb.sent);
            cb.check();

            p.begin_ice_ids().whenCompleted(cb.ids, cb.ex).whenSent(cb.sent);
            cb.check();

            p.begin_op().whenCompleted(cb.op, cb.ex).whenSent(cb.sent);
            cb.check();

            p.begin_op(cb.opAsync, null).whenSent((Ice.AsyncCallback)cb.sentAsync);
            cb.check();

            p.begin_op().whenCompleted(cb.ex).whenSent(cb.sent);
            cb.check();

            List<SentCallback> cbs = new List<SentCallback>();
            byte[] seq = new byte[10024];
            (new System.Random()).NextBytes(seq);
            testController.holdAdapter();
            try
            {
                Ice.AsyncResult r;
                do
                {
                    SentCallback cb2 = new SentCallback();
                    r = p.begin_opWithPayload(seq).whenCompleted(cb2.ex).whenSent(cb2.sent);
                    cbs.Add(cb2);
                }
                while(r.sentSynchronously());
            }
            finally
            {
                testController.resumeAdapter();
            }
            foreach(SentCallback cb3 in cbs)
            {
                cb3.check();
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing illegal arguments... ");
        Console.Out.Flush();
        {
            Ice.AsyncResult result;

            result = p.begin_op();
            p.end_op(result);
            try
            {
                p.end_op(result);
                test(false);
            }
            catch(System.ArgumentException)
            {
            }

            result = p.begin_op();
            try
            {
                p.end_opWithResult(result);
                test(false);
            }
            catch(System.ArgumentException)
            {
            }

            try
            {
                p.end_op(null);
                test(false);
            }
            catch(System.ArgumentException)
            {
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing unexpected exceptions from callback... ");
        Console.Out.Flush();
        {
            Test.TestIntfPrx q = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy"));
            ThrowType[] throwEx = new ThrowType[]{ ThrowType.LocalException, ThrowType.UserException,
                                                   ThrowType.OtherException };

            for(int i = 0; i < 3; ++i)
            {
                Thrower cb = new Thrower(throwEx[i]);

                p.begin_op(cb.opAsync, null);
                cb.check();

                p.begin_op().whenCompleted(cb.op, null);
                cb.check();

                q.begin_op().whenCompleted(cb.op, cb.ex);
                cb.check();

                p.begin_op().whenCompleted(cb.noOp, cb.ex).whenSent(cb.sent);
                cb.check();

                q.begin_op().whenCompleted(cb.ex);
                cb.check();
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing batch requests with proxy... ");
        Console.Out.Flush();
        {
            Cookie cookie = new Cookie(5);

            {
                //
                // AsyncResult.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.opBatch();
                FlushCallback cb = new FlushCallback(cookie);
                Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(cb.completedAsync, cookie);
                r.whenSent((Ice.AsyncCallback)cb.sentAsync);
                cb.check();
                test(r.isSent());
                test(r.IsCompleted);
                test(p.waitForBatch(2));
            }

            {
                //
                // AsyncResult exception.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.ice_getConnection().close(false);
                FlushExCallback cb = new FlushExCallback(cookie);
                Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(cb.completedAsync, cookie);
                r.whenSent((Ice.AsyncCallback)cb.sentAsync);
                cb.check();
                test(!r.isSent());
                test(r.IsCompleted);
                test(p.opBatchCount() == 0);
            }

            {
                //
                // Type-safe.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.opBatch();
                FlushCallback cb = new FlushCallback();
                Ice.AsyncResult r = b1.begin_ice_flushBatchRequests();
                r.whenCompleted(cb.exception);
                r.whenSent((Ice.SentCallback)cb.sent);
                cb.check();
                test(r.isSent());
                test(r.IsCompleted);
                test(p.waitForBatch(2));
            }

            {
                //
                // Type-safe exception.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.ice_getConnection().close(false);
                FlushExCallback cb = new FlushExCallback();
                Ice.AsyncResult r = b1.begin_ice_flushBatchRequests();
                r.whenCompleted(cb.exception);
                r.whenSent((Ice.SentCallback)cb.sent);
                cb.check();
                test(!r.isSent());
                test(r.IsCompleted);
                test(p.opBatchCount() == 0);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing batch requests with connection... ");
        Console.Out.Flush();
        {
            Cookie cookie = new Cookie(5);

            {
                //
                // AsyncResult.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.opBatch();
                FlushCallback cb = new FlushCallback(cookie);
                Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(cb.completedAsync, cookie);
                r.whenSent((Ice.AsyncCallback)cb.sentAsync);
                cb.check();
                test(r.isSent());
                test(r.IsCompleted);
                test(p.waitForBatch(2));
            }

            {
                //
                // AsyncResult exception.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.ice_getConnection().close(false);
                FlushExCallback cb = new FlushExCallback(cookie);
                Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(cb.completedAsync, cookie);
                r.whenSent((Ice.AsyncCallback)cb.sentAsync);
                cb.check();
                test(!r.isSent());
                test(r.IsCompleted);
                test(p.opBatchCount() == 0);
            }

            {
                //
                // Type-safe.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.opBatch();
                FlushCallback cb = new FlushCallback();
                Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests();
                r.whenCompleted(cb.exception);
                r.whenSent((Ice.SentCallback)cb.sent);
                cb.check();
                test(r.isSent());
                test(r.IsCompleted);
                test(p.waitForBatch(2));
            }

            {
                //
                // Type-safe exception.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.ice_getConnection().close(false);
                FlushExCallback cb = new FlushExCallback();
                Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests();
                r.whenCompleted(cb.exception);
                r.whenSent((Ice.SentCallback)cb.sent);
                cb.check();
                test(!r.isSent());
                test(r.IsCompleted);
                test(p.opBatchCount() == 0);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing batch requests with communicator... ");
        Console.Out.Flush();
        {
            Cookie cookie = new Cookie(5);

            {
                //
                // AsyncResult - 1 connection.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.opBatch();
                FlushCallback cb = new FlushCallback(cookie);
                Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie);
                r.whenSent((Ice.AsyncCallback)cb.sentAsync);
                cb.check();
                test(r.isSent());
                test(r.IsCompleted);
                test(p.waitForBatch(2));
            }

            {
                //
                // AsyncResult exception - 1 connection.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.ice_getConnection().close(false);
                FlushCallback cb = new FlushCallback(cookie);
                Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie);
                r.whenSent((Ice.AsyncCallback)cb.sentAsync);
                cb.check();
                test(r.isSent()); // Exceptions are ignored!
                test(r.IsCompleted);
                test(p.opBatchCount() == 0);
            }

            {
                //
                // AsyncResult - 2 connections.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                b2.ice_getConnection(); // Ensure connection is established.
                b1.opBatch();
                b1.opBatch();
                b2.opBatch();
                b2.opBatch();
                FlushCallback cb = new FlushCallback(cookie);
                Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie);
                r.whenSent((Ice.AsyncCallback)cb.sentAsync);
                cb.check();
                test(r.isSent());
                test(r.IsCompleted);
                test(p.waitForBatch(4));
            }

            {
                //
                // AsyncResult exception - 2 connections - 1 failure.
                //
                // All connections should be flushed even if there are failures on some connections.
                // Exceptions should not be reported.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                b2.ice_getConnection(); // Ensure connection is established.
                b1.opBatch();
                b2.opBatch();
                b1.ice_getConnection().close(false);
                FlushCallback cb = new FlushCallback(cookie);
                Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie);
                r.whenSent((Ice.AsyncCallback)cb.sentAsync);
                cb.check();
                test(r.isSent()); // Exceptions are ignored!
                test(r.IsCompleted);
                test(p.waitForBatch(1));
            }

            {
                //
                // AsyncResult exception - 2 connections - 2 failures.
                //
                // The sent callback should be invoked even if all connections fail.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                b2.ice_getConnection(); // Ensure connection is established.
                b1.opBatch();
                b2.opBatch();
                b1.ice_getConnection().close(false);
                b2.ice_getConnection().close(false);
                FlushCallback cb = new FlushCallback(cookie);
                Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie);
                r.whenSent((Ice.AsyncCallback)cb.sentAsync);
                cb.check();
                test(r.isSent()); // Exceptions are ignored!
                test(r.IsCompleted);
                test(p.opBatchCount() == 0);
            }

            {
                //
                // Type-safe - 1 connection.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.opBatch();
                FlushCallback cb = new FlushCallback();
                Ice.AsyncResult r = communicator.begin_flushBatchRequests();
                r.whenCompleted(cb.exception);
                r.whenSent((Ice.SentCallback)cb.sent);
                cb.check();
                test(r.isSent());
                test(r.IsCompleted);
                test(p.waitForBatch(2));
            }

            {
                //
                // Type-safe exception - 1 connection.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                b1.opBatch();
                b1.ice_getConnection().close(false);
                FlushCallback cb = new FlushCallback();
                Ice.AsyncResult r = communicator.begin_flushBatchRequests();
                r.whenCompleted(cb.exception);
                r.whenSent((Ice.SentCallback)cb.sent);
                cb.check();
                test(r.isSent()); // Exceptions are ignored!
                test(r.IsCompleted);
                test(p.opBatchCount() == 0);
            }

            {
                //
                // 2 connections.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                b2.ice_getConnection(); // Ensure connection is established.
                b1.opBatch();
                b1.opBatch();
                b2.opBatch();
                b2.opBatch();
                FlushCallback cb = new FlushCallback();
                Ice.AsyncResult r = communicator.begin_flushBatchRequests();
                r.whenCompleted(cb.exception);
                r.whenSent((Ice.SentCallback)cb.sent);
                cb.check();
                test(r.isSent());
                test(r.IsCompleted);
                test(p.waitForBatch(4));
            }

            {
                //
                // Exception - 2 connections - 1 failure.
                //
                // All connections should be flushed even if there are failures on some connections.
                // Exceptions should not be reported.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                b2.ice_getConnection(); // Ensure connection is established.
                b1.opBatch();
                b2.opBatch();
                b1.ice_getConnection().close(false);
                FlushCallback cb = new FlushCallback();
                Ice.AsyncResult r = communicator.begin_flushBatchRequests();
                r.whenCompleted(cb.exception);
                r.whenSent((Ice.SentCallback)cb.sent);
                cb.check();
                test(r.isSent()); // Exceptions are ignored!
                test(r.IsCompleted);
                test(p.waitForBatch(1));
            }

            {
                //
                // Exception - 2 connections - 2 failures.
                //
                // The sent callback should be invoked even if all connections fail.
                //
                test(p.opBatchCount() == 0);
                TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway();
                TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway();
                b2.ice_getConnection(); // Ensure connection is established.
                b1.opBatch();
                b2.opBatch();
                b1.ice_getConnection().close(false);
                b2.ice_getConnection().close(false);
                FlushCallback cb = new FlushCallback();
                Ice.AsyncResult r = communicator.begin_flushBatchRequests();
                r.whenCompleted(cb.exception);
                r.whenSent((Ice.SentCallback)cb.sent);
                cb.check();
                test(r.isSent()); // Exceptions are ignored!
                test(r.IsCompleted);
                test(p.opBatchCount() == 0);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing AsyncResult operations... ");
        Console.Out.Flush();
        {
            testController.holdAdapter();
            Ice.AsyncResult r1;
            Ice.AsyncResult r2;
            try
            {
                r1 = p.begin_op();
                byte[] seq = new byte[10024];
                (new System.Random()).NextBytes(seq);
                while((r2 = p.begin_opWithPayload(seq)).sentSynchronously());

                test(r1.sentSynchronously() && r1.isSent() && !r1.isCompleted_() ||
                     !r1.sentSynchronously() && !r1.isCompleted_());

                test(!r2.sentSynchronously() && !r2.isCompleted_());

                test(!r1.IsCompleted && !r1.CompletedSynchronously);
                test(!r2.IsCompleted && !r2.CompletedSynchronously);
            }
            finally
            {
                testController.resumeAdapter();
            }

            WaitHandle w1 = r1.AsyncWaitHandle;
            WaitHandle w2 = r2.AsyncWaitHandle;

            r1.waitForSent();
            test(r1.isSent());

            r2.waitForSent();
            test(r2.isSent());

            r1.waitForCompleted();
            test(r1.isCompleted_());
            w1.WaitOne();

            r2.waitForCompleted();
            test(r2.isCompleted_());
            w2.WaitOne();

            test(r1.getOperation().Equals("op"));
            test(r2.getOperation().Equals("opWithPayload"));
        }
        Console.Out.WriteLine("ok");

        p.shutdown();
    }
Beispiel #54
0
 public void BroadcastToChannel(String ChannelName, TJSONValue Msg, BroadcastToChannelCallback callback = null, ExceptionCallback ExCal = null)
 {
     DSRESTCommand cmd = getConnection().CreateCommand();
     cmd.setRequestType(DSHTTPRequestType.POST);
     cmd.setText("DSAdmin.BroadcastToChannel");
     cmd.prepare(get_DSAdmin_BroadcastToChannel_Metadata());
     BroadcastToChannelDelegate BroadcastToChannelDel = () => {
       if (callback != null)
       {
     callback.DynamicInvoke(cmd.getParameter(2).getValue().GetAsBoolean());
       }
     };
     cmd.getParameter(0).getValue().SetAsString(ChannelName);
     cmd.getParameter(1).getValue().SetAsJSONValue(Msg);
     getConnection().execute(cmd, this, BroadcastToChannelDel, ExCal);
 }
Beispiel #55
0
 public virtual AbstractBootstrap OnError(ExceptionCallback exceptionCallback)
 {
     ExceptionCallback = exceptionCallback;
     return this;
 }
Beispiel #56
0
 public DSAdmin(DSRESTConnection Connection, ExceptionCallback ExCal)
 {
     BaseExCal = ExCal;
     connection = Connection;
 }