Beispiel #1
0
        //Method for completion callback
        private void VerifyTiles_OnComplete(IAsyncResult res)
        {
            bool        result;
            VerifyDelg  verifyDelg;
            AsyncResult asyncObj = (AsyncResult)res;

            //makes sure end invoke isn't called more than once
            if (asyncObj.EndInvokeCalled == false)
            {
                verifyDelg = (VerifyDelg)asyncObj.AsyncDelegate;
                //gets the result of the call
                result = verifyDelg.EndInvoke(asyncObj);

                //prints result to console in biz server
                if (result == true)
                {
                    Console.WriteLine("Success");
                }
                else if (result == false)
                {
                    Console.WriteLine("Failure");
                }

                //to do the remote callback for the client
                ITMBizControllerCallback cb = (ITMBizControllerCallback)asyncObj.AsyncState;
                cb.OnVerificationComplete(result);
            }
            asyncObj.AsyncWaitHandle.Close();
        }
        private void CallbackFunc(IAsyncResult result)
        {
            bool           VerifyResult;
            VerifyTileDelg Delg;
            AsyncResult    asyncobject = (AsyncResult)result;

            if (asyncobject.EndInvokeCalled == false)
            {
                Delg         = (VerifyTileDelg)asyncobject.AsyncDelegate;
                VerifyResult = Delg.EndInvoke(asyncobject);
                if (VerifyResult)
                {
                    Console.WriteLine("Sucess");
                }
                else
                {
                    Console.WriteLine("fail");
                }
                ITMBizControllerCallback cb = (ITMBizControllerCallback)asyncobject.AsyncState;
                cb.OnVerificationComplete(VerifyResult);
            }
            asyncobject.AsyncWaitHandle.Close();
        }
        /// <summary>
        /// VerifyTiles_OnComplete
        /// Callback funtion for Delgate
        /// gets the result from the call and sends it to the Client
        /// </summary>
        /// <param name="res"></param>
        public void VerifyTiles_OnComplete(IAsyncResult res)
        {
            bool                     iResult = false;             // result of verification
            VerifyOperation          del;                         // delegate function reference
            ITMBizControllerCallback ob       = null;             // remote client object reference
            AsyncResult              asyncObj = (AsyncResult)res; // result from async function

            try
            {
                if (asyncObj.EndInvokeCalled == false)                       // if EndInvoke() has not been called
                {
                    del     = (VerifyOperation)asyncObj.AsyncDelegate;       // gain access to delegate
                    ob      = (ITMBizControllerCallback)asyncObj.AsyncState; // get remote client obj reference
                    iResult = del.EndInvoke(asyncObj);                       // retrieve result
                }
                asyncObj.AsyncWaitHandle.Close();
                Console.WriteLine("Verification Complete.\n");
                ob.OnVerificationComplete(iResult);     // send result to client
            }
            catch (CommunicationException e)
            {
                Console.WriteLine("\nError: Sending Tile Verification to Client\n" + e.Message);
            }
        }