当前位置: 首页>>代码示例>>C#>>正文


C# SendOrPostCallback类代码示例

本文整理汇总了C#中SendOrPostCallback的典型用法代码示例。如果您正苦于以下问题:C# SendOrPostCallback类的具体用法?C# SendOrPostCallback怎么用?C# SendOrPostCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SendOrPostCallback类属于命名空间,在下文中一共展示了SendOrPostCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VerifyDelegateNotNull

 private void VerifyDelegateNotNull(SendOrPostCallback d)
 {
     if (d == null)
     {
         throw new ArgumentNullException(SR.GetString("Async_NullDelegate"), "d");
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:AsyncOperation.cs

示例2: Post

 public override void Post(SendOrPostCallback d, object state)
 {
     lock (_postedCallbacks)
     {
         _postedCallbacks.Add(Tuple.Create(d, state));
     }
 }
开发者ID:rdterner,项目名称:Perspex,代码行数:7,代码来源:UnitTestSynchronizationContext.cs

示例3: AsyncSendData

 private AsyncSendData(AsyncDataHandler handler, Uri uriToUse, AtomEntry entry, AtomFeed feed,
     SendOrPostCallback callback, object userData, bool parseFeed)
     : base(uriToUse, null, userData, callback, parseFeed) {
     this.DataHandler = handler;
     this.entry = entry;
     this.Feed = feed;
 }
开发者ID:Zelxin,项目名称:RPiKeg,代码行数:7,代码来源:asyncservice.cs

示例4: Post

        public void Post(SendOrPostCallback callback, object state)
        {
            #region Contracts

            if (callback == null) throw new ArgumentNullException();

            #endregion

            // Create
            Action action = delegate()
            {
                try
                {
                    callback(state);
                }
                catch (Exception ex)
                {
                    Debug.Fail(string.Format("Delegate:{0}, State:{1}, Message:{2}", callback.GetType(), "Exception", ex.Message));
                }
            };

            // Set
            lock (_syncRoot)
            {
                // Require
                if (_operateState != OperateState.Started) throw new InvalidOperationException();
                if (_executeThreadState != OperateState.Started) throw new InvalidOperationException();

                // Attach
                _executeActionQueue.Enqueue(action);
            }
        }
开发者ID:JPomichael,项目名称:CLK,代码行数:32,代码来源:STAThread.cs

示例5: Functions

 public Functions()
 {
     #region Initialize Delegates for Database Commands
     onGetProfileCompletedDelegate = new SendOrPostCallback(GetProfileCompleted);
     onGetServersCompletedDelegate = new SendOrPostCallback(GetServersCompleted);
     #endregion
 }
开发者ID:jedlimke,项目名称:csharp.tent,代码行数:7,代码来源:Functions.cs

示例6: Post

        public virtual void Post(SendOrPostCallback d, object state) {
#if (dotNET10 || dotNET11 || dotNETCF10)
            ThreadPool.QueueUserWorkItem(new WaitCallback(d), state);
#else
            ThreadPool.QueueUserWorkItem(d.Invoke, state);
#endif
        }
开发者ID:cooclsee,项目名称:hprose-dotnet,代码行数:7,代码来源:SynchronizationContext.cs

示例7: CallbackItem

 public CallbackItem(SendOrPostCallback item, object state)
 {
     this.Id = Guid.NewGuid();
     this.executionCompleted = new ManualResetEvent(false);
     this.callback = item;
     this.state = state;
 }
开发者ID:namesecured,项目名称:TestSync,代码行数:7,代码来源:CallbackItem.cs

示例8: AsyncPost

 /// <summary>
 /// Post a call to the specified method on the creator thread
 /// </summary>
 /// <param name="callback">Method that is to be called</param>
 /// <param name="state">Method parameter/state</param>
 public void AsyncPost(SendOrPostCallback callback, object state)
 {
     if (IsAsyncCreatorThread)
         callback(state); // Call the method directly
     else
         AsynchronizationContext.Post(callback, state);  // Post on creator thread
 }
开发者ID:Gainedge,项目名称:BetterExplorer,代码行数:12,代码来源:AsyncContext.cs

示例9: Post

        public override async void Post(SendOrPostCallback d, object state)
        {
            // The call to Post() may be the state machine signaling that an exception is
            // about to be thrown, so we make sure the operation count gets incremented
            // before the Task.Run, and then decrement the count when the operation is done.
            OperationStarted();

            try
            {
                // await and eat exceptions that come from this post
                // We could get a thread abort, so we need to handle that
                await Task.Run(() =>
                {
                    try
                    {
                        Send(d, state);
                    }
                    finally
                    {
                        OperationCompleted();
                    }
                }).ConfigureAwait(false);
            }
            catch { }
        }
开发者ID:kouweizhong,项目名称:xunit,代码行数:25,代码来源:AsyncTestSyncContext.cs

示例10: Invoke

 void Invoke(SendOrPostCallback d, object state, bool sync)
 {
     if (sync)
         sc.Send(d,state);
     else
         sc.Post(d, state);
 }
开发者ID:winterheart,项目名称:game-utilities,代码行数:7,代码来源:BrowserController.cs

示例11: SynchronizedCall

        /// <summary>
        /// Initializes a new instance of the <see cref="SynchronizedCall"/> class.
        /// </summary>
        /// <param name="callback">The call to marshal.</param>
        /// <param name="state">The state to provide to the call. <see langword="null"/> is fine if you don't need to include any state.</param>
        public SynchronizedCall(SendOrPostCallback callback, object state)
        {
            Throw.If.Null(callback, "callback");

            this.callback = callback;
            this.state = state;
        }
开发者ID:qmfrederik,项目名称:remoteviewing,代码行数:12,代码来源:SynchronizedCall.cs

示例12: Post

        public void Post(string resource, Dictionary<string, string> parameters, SendOrPostCallback onComplete) {
            var uriPath = resource;
            var uri = new Uri(uriPath, UriKind.Absolute);
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);
            httpWebRequest.Method = "POST";

            var writeRequest = new AsyncCallback(e => {
                httpWebRequest.ContentType = "application/x-www-form-urlencoded";

                var stream = httpWebRequest.EndGetRequestStream(e);
                var postData = string.Empty;

                foreach (var key in parameters.Keys) {
                    postData += key + "=" + parameters[key] + "&";
                }

                var streamWriter = new StreamWriter(stream);
                streamWriter.Write(postData);
                streamWriter.Close();
                stream.Close();

                httpWebRequest.BeginGetResponse(x => synchronizationContext.Post(onComplete, x), null);
            });

            httpWebRequest.BeginGetRequestStream(writeRequest, null);
        }
开发者ID:slieser,项目名称:sandbox2,代码行数:26,代码来源:Rest.cs

示例13: Post

        public override void Post(SendOrPostCallback d, object state)
        {
            if (mQueue.IsAddingCompleted)
                throw new SynchronizationContextCompletedException();

            mQueue.Add(new KeyValuePair<SendOrPostCallback, object>(d, state));
        }
开发者ID:afj88,项目名称:DBBranchManager,代码行数:7,代码来源:SingleThreadSynchronizationContext.cs

示例14: Post

 public static void Post(SendOrPostCallback callback, object state = null)
 {
     lock (s_posts)
     {
         s_posts.Add(Tuple.Create(callback, state));
     }
 }
开发者ID:SaladLab,项目名称:TicTacToe,代码行数:7,代码来源:ChannelEventDispatcher.cs

示例15: Post

		public override void Post(SendOrPostCallback d, object state)
		{
			lock (list)
			{
				list.Add(() => d(state));
			}
		}
开发者ID:Zamir7,项目名称:urho,代码行数:7,代码来源:ListBasedUpdateSynchronizationContext.cs


注:本文中的SendOrPostCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。