コード例 #1
0
        private void Receive()
        {
            //if handleFlag is true, execute
            if (handleFlag)
            {
                byte[] receiveData = mStateObject.memoryStream.ToArray();
                if (TransferUtil.isServerCall(receiveData[0]))
                {
                    //it is server call
                    ExecuteDelegate executeDelegate = delegate() {
                        handleServerCall(receiveData);
                    };
                    executeDelegate.BeginInvoke(null, null);

                    //ThreadPool.QueueUserWorkItem(handleServerCall, receiveData);
                }
                else
                {
                    //it is server response
                    receiveQueue.Enqueue(receiveData);
                }

                handleFlag          = false;
                firsttime           = true;
                expectReceiveLength = 0;
                receiveLength       = 0;

                //reset memory stream
                mStateObject.memoryStream.Position = 0;
                mStateObject.memoryStream.SetLength(0);
            }
            Socket socket = mStateObject.workSocket;

            socket.BeginReceive(mStateObject.buffer, 0, StateObject.BUFFER_SIZE, SocketFlags.None, new AsyncCallback(ReceiveCallback), mStateObject);
        }
コード例 #2
0
ファイル: Window1.xaml.cs プロジェクト: paulomouat/spikes
 private void RaiseSpecificButton_Click(object sender, RoutedEventArgs e)
 {
     var d = new DummyServer();
     var ed = new ExecuteDelegate(d.Execute);
     Write("Raising specific exception...");
     ed.BeginInvoke(314, AsyncHelper.DispatchExceptions(ResultReady), ed);
 }
コード例 #3
0
        /**
         * Dispatch request to a appointed socket connection.
         * @param to TransferObject
         * @return Object
         */
        public static object execute(TransferObject to)
        {
            Object retObject = null;

            if (connectionList == null)
            {
                initialize();
            }

            String connectionName = to.getConnectionName();

            foreach (SocketConnection connection in connectionList)
            {
                if (connection.getName().Equals(connectionName))
                {
                    if (to.isAsynchronous())
                    {
                        ExecuteDelegate executeDelegate = delegate(SocketConnection socketConnection, TransferObject transferObject) {
                            return(socketConnection.execute(transferObject));
                        };
                        IAsyncResult asyncResult = executeDelegate.BeginInvoke(connection, to, null, null);
                        Future       future      = new Future(executeDelegate, asyncResult);
                        retObject = future;
                    }
                    else
                    {
                        retObject = connection.execute(to);
                    }
                }
            }

            return(retObject);
        }
コード例 #4
0
        private static void ExecuteWrapper()
        {
            var d  = new DummyServer();
            var ed = new ExecuteDelegate(d.Execute);

            ed.BeginInvoke(271, AsyncHelper.DispatchExceptions(ResultReady), ed);
        }
コード例 #5
0
        private void RaiseGeneralButton_Click(object sender, RoutedEventArgs e)
        {
            var d  = new DummyServer();
            var ed = new ExecuteDelegate(d.Execute);

            Write("Raising general exception...");
            ed.BeginInvoke(271, AsyncHelper.DispatchExceptions(ResultReady), ed);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: paulomouat/spikes
        private static void ExecuteAsync()
        {
            var d = new DummyServer();
            var ed = new ExecuteDelegate(d.Execute);
            ed.BeginInvoke(11, ResultReady, ed);

            var ed2 = new ExecuteDelegate2(d.Execute);
            ed2.BeginInvoke(11, 22, ResultReady2, ed2);
        }
コード例 #7
0
 public JobAsyncResult(IJob job, AsyncCallback asyncCallback, JobExecutionContext context,
                       object asyncState)
 {
     this.job             = job;
     this.executeDelegate = job.Execute;
     this.asyncCallback   = asyncCallback;
     this.asyncState      = asyncState;
     inner = executeDelegate.BeginInvoke(context, Callback, asyncState);
 }
            public void DoWork(NorthwindConfig config, SyncFeedDigest syncDigestInfo)
            {
                ExecuteDelegate worker            = new ExecuteDelegate(Execute);
                AsyncCallback   completedCallback = new AsyncCallback(ExecuteCompletedCallback);

                AsyncOperation async = AsyncOperationManager.CreateOperation(null);

                // Begin asynchronous method call
                worker.BeginInvoke(config, syncDigestInfo, completedCallback, async);
            }
コード例 #9
0
        private static void ExecuteAsync()
        {
            var d  = new DummyServer();
            var ed = new ExecuteDelegate(d.Execute);

            ed.BeginInvoke(11, ResultReady, ed);

            var ed2 = new ExecuteDelegate2(d.Execute);

            ed2.BeginInvoke(11, 22, ResultReady2, ed2);
        }
コード例 #10
0
        protected internal override void _BeginExecute()
        {
            if (_mdx == "")
            {
                BuildMdx();
            }

            if (_olapTaskGuid == Guid.Empty)
            {
                _olapTaskGuid = System.Guid.NewGuid();
            }
            string taskTag = string.Format("User: {0} ({1}), OlapReport: {2} ({3})",
                                           this._owner.Name, this._owner.ID, this.Name, this.ID);

            FI.Common.DataAccess.IOlapSystemDA dacOlapSystem = DataAccessFactory.Instance.GetOlapSystemDA();
            _asyncDelegate = new ExecuteDelegate(dacOlapSystem.BuildCellset);
            _asyncResult   = _asyncDelegate.BeginInvoke(Schema.Server, Schema.Database, _mdx, _olapTaskGuid.ToString(), taskTag, null, null);
        }
コード例 #11
0
ファイル: Ping.cs プロジェクト: ewin66/Forge
        /// <summary>
        /// Begins the execute.
        /// </summary>
        /// <param name="host">The host.</param>
        /// <param name="dataLength">Length of the data.</param>
        /// <param name="pingCount">The ping count.</param>
        /// <param name="timeout">The timeout.</param>
        /// <param name="waitTimeBetweenAttempts">The wait time between attempts.</param>
        /// <param name="callback">The callback.</param>
        /// <param name="state">The state.</param>
        /// <returns>Async property</returns>
        public IAsyncResult BeginExecute(string host, int dataLength, int pingCount, int timeout, int waitTimeBetweenAttempts, AsyncCallback callback, object state)
        {
            Interlocked.Increment(ref mAsyncActiveExecutionCount);
            ExecuteDelegate d = new ExecuteDelegate(this.Execute);

            if (this.mAsyncActiveExecutionEvent == null)
            {
                lock (LOCK_EXECUTE)
                {
                    if (this.mAsyncActiveExecutionEvent == null)
                    {
                        this.mAsyncActiveExecutionEvent = new AutoResetEvent(true);
                    }
                }
            }
            this.mAsyncActiveExecutionEvent.WaitOne();
            this.mExecutionDelegate = d;
            return(d.BeginInvoke(host, dataLength, pingCount, timeout, waitTimeBetweenAttempts, callback, state));
        }
コード例 #12
0
        public void ProcessMappings(IEnumerable <Mapping> mappings, BuildStatusChangeEvent statusChanged, BuildDetail buildDetail, IPostDeployAction postDeployAction, int eventId)
        {
            var applicableMappings = from mapping in mappings
                                     where _mappingEvaluator.DoesMappingApply(mapping, statusChanged, buildDetail.Status.ToString())
                                     select mapping;

            foreach (var mapping in applicableMappings)
            {
                TraceHelper.TraceInformation(TraceSwitches.TfsDeployer,
                                             "Matching mapping found, executing, Computer:{0}, Script:{1}",
                                             mapping.Computer,
                                             mapping.Script);

                var deploymentId = _deploymentEventRecorder.RecordQueued(eventId, mapping.Script, mapping.Queue);

                var             executor        = _executorFactory();
                ExecuteDelegate executeDelegate = executor.Execute;
                executeDelegate.BeginInvoke(statusChanged, buildDetail, mapping, postDeployAction, deploymentId, ExecuteDelegateCallback, executeDelegate);
            }
        }
コード例 #13
0
            public void DoWork(NorthwindConfig config, SyncFeed feed)
            {
                ExecuteDelegate worker = new ExecuteDelegate(Execute);
                AsyncCallback completedCallback = new AsyncCallback(ExecuteCompletedCallback);

                AsyncOperation async = AsyncOperationManager.CreateOperation(null);

                // Begin asynchronous method call
                worker.BeginInvoke(config, feed, completedCallback, async);
            }
コード例 #14
0
ファイル: DefaultJobRunner.cs プロジェクト: ralescano/castle
			public JobAsyncResult(IJob job, AsyncCallback asyncCallback, JobExecutionContext context,
			                            object asyncState)
			{
				this.job = job;
				this.executeDelegate = job.Execute;
				this.asyncCallback = asyncCallback;
				this.asyncState = asyncState;
				inner = executeDelegate.BeginInvoke(context, Callback, asyncState);
			}
コード例 #15
0
 public void Invoke(string config, string assemblydir, string name, params object[] args)
 {
     _ed.BeginInvoke(config, assemblydir, name, args, null, null);
 }
コード例 #16
0
ファイル: Program.cs プロジェクト: paulomouat/spikes
 private static void ExecuteWrapper()
 {
     var d = new DummyServer();
     var ed = new ExecuteDelegate(d.Execute);
     ed.BeginInvoke(271, AsyncHelper.DispatchExceptions(ResultReady), ed);
 }