本文整理汇总了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");
}
}
示例2: Post
public override void Post(SendOrPostCallback d, object state)
{
lock (_postedCallbacks)
{
_postedCallbacks.Add(Tuple.Create(d, state));
}
}
示例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;
}
示例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);
}
}
示例5: Functions
public Functions()
{
#region Initialize Delegates for Database Commands
onGetProfileCompletedDelegate = new SendOrPostCallback(GetProfileCompleted);
onGetServersCompletedDelegate = new SendOrPostCallback(GetServersCompleted);
#endregion
}
示例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
}
示例7: CallbackItem
public CallbackItem(SendOrPostCallback item, object state)
{
this.Id = Guid.NewGuid();
this.executionCompleted = new ManualResetEvent(false);
this.callback = item;
this.state = state;
}
示例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
}
示例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 { }
}
示例10: Invoke
void Invoke(SendOrPostCallback d, object state, bool sync)
{
if (sync)
sc.Send(d,state);
else
sc.Post(d, state);
}
示例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;
}
示例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);
}
示例13: Post
public override void Post(SendOrPostCallback d, object state)
{
if (mQueue.IsAddingCompleted)
throw new SynchronizationContextCompletedException();
mQueue.Add(new KeyValuePair<SendOrPostCallback, object>(d, state));
}
示例14: Post
public static void Post(SendOrPostCallback callback, object state = null)
{
lock (s_posts)
{
s_posts.Add(Tuple.Create(callback, state));
}
}
示例15: Post
public override void Post(SendOrPostCallback d, object state)
{
lock (list)
{
list.Add(() => d(state));
}
}