本文整理汇总了C#中AsyncResult类的典型用法代码示例。如果您正苦于以下问题:C# AsyncResult类的具体用法?C# AsyncResult怎么用?C# AsyncResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AsyncResult类属于命名空间,在下文中一共展示了AsyncResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BeginRead
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
{
read = new AsyncResult() { AsyncState = state };
read.bytesRead = Read(buffer, offset, count);
callback(read);
return read;
}
开发者ID:nithinphilips,项目名称:bbwifimusicsync,代码行数:7,代码来源:SynchronousMemoryStream.cs
示例2: BeginGetQuestionnaireTemplateSummary
public IAsyncResult BeginGetQuestionnaireTemplateSummary(QuestionnaireTemplate questionnaireTemplate, AsyncCallback callback, object asyncState)
{
var result = new AsyncResult<QuestionnaireTemplateSummary>(callback, asyncState);
HandleBeginGetQuestionnaireTemplateSummary(result);
return result;
}
开发者ID:CarlosVV,项目名称:mediavf,代码行数:7,代码来源:MockQuestionnaireService.cs
示例3: BeginWrite
public IAsyncResult BeginWrite(ReaderWriterGateCallback callback, Object state,
AsyncCallback asyncCallback, Object asyncState) {
AsyncResult<Object> ar = new AsyncResult<Object>(asyncCallback, asyncState);
ReaderWriterGateReleaser releaser = new ReaderWriterGateReleaser(callback, this, false, state, ar);
m_syncLock.Enter(true);
switch (m_state) {
case ReaderWriterGateStates.Free: // If Free "RFW -> OBW, invoke, return
case ReaderWriterGateStates.ReservedForWriter:
m_state = ReaderWriterGateStates.OwnedByWriter;
ThreadPool.QueueUserWorkItem(releaser.Invoke);
break;
case ReaderWriterGateStates.OwnedByReaders: // If OBR | OBRAWP -> OBRAWP, queue, return
case ReaderWriterGateStates.OwnedByReadersAndWriterPending:
m_state = ReaderWriterGateStates.OwnedByReadersAndWriterPending;
m_qWriteRequests.Enqueue(releaser);
break;
case ReaderWriterGateStates.OwnedByWriter: // If OBW, queue, return
m_qWriteRequests.Enqueue(releaser);
break;
}
m_syncLock.Leave();
return ar;
}
开发者ID:blinds52,项目名称:PowerThreading,代码行数:25,代码来源:ReaderWriterGate.cs
示例4: BeginGetQuestionnaire
public IAsyncResult BeginGetQuestionnaire(AsyncCallback callback, object asyncState)
{
var result = new AsyncResult<Questionnaire>(callback, asyncState);
HandleBeginGetQuestionnaire(result);
return result;
}
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:7,代码来源:MockQuestionnaireService.cs
示例5: BeginConnect
public IAsyncResult BeginConnect(string hostName, int port, AsyncCallback callback = null, object state = null)
{
var ar = new AsyncResult(state) { Hostname = hostName, Port = port };
ar.Client = new TcpClient();
ar.Client.BeginConnect(_info.ProxyHostname, _info.ProxyPort, OnConnected, ar);
return ar;
}
开发者ID:cyruslopez,项目名称:Floe,代码行数:7,代码来源:SocksTcpClient.cs
示例6: BeginDownloadXml
public override IAsyncResult BeginDownloadXml(Uri feeduri, AsyncCallback callback)
{
#if !WINDOWS_PHONE
if (!IsolatedStorageFile.IsEnabled) throw new MissingFeedException("IsolatedStorage is not enabled! Cannot access files from IsolatedStorage!");
#endif
try
{
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
if(!PingFeed(feeduri, store)) throw new MissingFeedException(string.Format("Could not find feed at location {0}", feeduri));
using (var stream = new IsolatedStorageFileStream(feeduri.OriginalString, FileMode.Open,
FileAccess.Read, store))
{
using(var reader = new StreamReader(stream))
{
var strOutput = reader.ReadToEnd();
//Fake the async result
var result = new AsyncResult<FeedTuple>(callback, new FeedTuple { FeedContent = strOutput, FeedUri = feeduri }, true);
if (callback != null) callback.Invoke(result);
return result;
}
}
}
}
catch (IsolatedStorageException ex)
{
throw new MissingFeedException(string.Format("Unable to open feed at {0}", feeduri), ex);
}
}
开发者ID:GuiBGP,项目名称:qdfeed,代码行数:32,代码来源:IsolatedStorageFeedFactory.cs
示例7: BeginGetQuestionnaireTemplates
public IAsyncResult BeginGetQuestionnaireTemplates(AsyncCallback callback, object asyncState)
{
var result = new AsyncResult<IEnumerable<QuestionnaireTemplate>>(callback, asyncState);
HandleBeginGetQuestionnaireTemplates(result);
return result;
}
开发者ID:CarlosVV,项目名称:mediavf,代码行数:7,代码来源:MockQuestionnaireService.cs
示例8: WhenCreated_ThenIsNotComplete
public void WhenCreated_ThenIsNotComplete()
{
var result = new AsyncResult<object>(null, this);
Assert.IsFalse(result.IsCompleted);
Assert.IsFalse(result.CompletedSynchronously);
}
开发者ID:eslahi,项目名称:prism,代码行数:7,代码来源:AsyncResultFixture.cs
示例9: when_asyncressult_completes_on_different_thread
public when_asyncressult_completes_on_different_thread()
{
asyncResult = new AsyncResult<int>(ar => Thread.VolatileWrite(ref callbackWasInvoked, 1), null);
ThreadPool.QueueUserWorkItem(_ => asyncResult.Complete(true, ExpectedResult));
// give the thread-pool thread time to invoke the callback
Thread.Sleep(100);
}
开发者ID:peteraritchie,项目名称:EffectiveAsyncResult,代码行数:7,代码来源:when_asyncressult_completes_on_different_thread.cs
示例10: BeginSubmitResponses
public IAsyncResult BeginSubmitResponses(Questionnaire questionnaire, AsyncCallback callback, object asyncState)
{
var result = new AsyncResult<object>(callback, asyncState);
HandleBeginSubmitResponses(result);
return result;
}
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:7,代码来源:MockQuestionnaireService.cs
示例11: SetResult
public void SetResult(AsyncResult asyncResult, object result)
{
lock (this._Lock)
{
List<TemporalAsyncResult> willRemovedTemporalAsyncResults = new List<TemporalAsyncResult>();
DateTime now = DateTime.UtcNow;
foreach(TemporalAsyncResult item in this._TemporalAsyncResults.Values)
{
if (now - item.TimeStamp > this._LiveTime)
{
willRemovedTemporalAsyncResults.Add(item);
}
}
foreach (TemporalAsyncResult item in willRemovedTemporalAsyncResults)
{
//AppDebug.LogEvent("AsyncResultManager.SetResult", string.Format("Delete timeout async result {0}, {1}", item.AsyncResult.Id, item.AsyncResult.MethodName), System.Diagnostics.EventLogEntryType.Information);
this._Results.Remove(item.AsyncResult.Id);
this._TemporalAsyncResults.Remove(item.AsyncResult.Id);
}
//AppDebug.LogEvent("AsyncResultManager.SetResult", string.Format("Set result of {0}, {1}", asyncResult.Id, asyncResult.MethodName), System.Diagnostics.EventLogEntryType.Information);
this._Results.Add(asyncResult.Id, result);
this._TemporalAsyncResults.Add(asyncResult.Id, new TemporalAsyncResult(asyncResult));
}
}
开发者ID:RobertHu,项目名称:TraderServer,代码行数:26,代码来源:AsyncResultManager.cs
示例12: Finally
private static void Finally(AsyncResult result, Exception currentException)
{
SqlWorkflowInstanceStoreAsyncResult result2 = result as SqlWorkflowInstanceStoreAsyncResult;
try
{
if (result2.DependentTransaction != null)
{
using (result2.DependentTransaction)
{
result2.DependentTransaction.Complete();
}
}
}
catch (TransactionException)
{
if (currentException == null)
{
throw;
}
}
finally
{
result2.OnCommandCompletion();
result2.ClearMembers();
StoreUtilities.TraceSqlCommand(result2.sqlCommand, false);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:SqlWorkflowInstanceStoreAsyncResult.cs
示例13: WhenCompleted_ThenESetsResult
public void WhenCompleted_ThenESetsResult()
{
var result = new AsyncResult<object>(null, null);
result.SetComplete(this, true);
Assert.AreSame(this, result.Result);
}
开发者ID:eslahi,项目名称:prism,代码行数:8,代码来源:AsyncResultFixture.cs
示例14: BeginReceiveMessage
public IAsyncResult BeginReceiveMessage(AsyncCallback asyncCallback, object state)
{
var asyncResult = new AsyncResult<string>(asyncCallback, state);
ReturnMessageOrBeginReceive(asyncResult, true);
return asyncResult;
}
开发者ID:Cooke,项目名称:DotNetWebSocket,代码行数:8,代码来源:WebSocket.cs
示例15: BeginWrite
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
{
//Console.WriteLine("SMS writing " + count + " bytes.");
write = new AsyncResult() { AsyncState = state };
Write(buffer, offset, count);
callback(write);
return write;
}
开发者ID:nithinphilips,项目名称:bbwifimusicsync,代码行数:8,代码来源:SynchronousMemoryStream.cs
示例16: BeginAsyncAction
public IAsyncResult BeginAsyncAction(Action action)
{
var asyncresult = new AsyncResult()
{
Action = action
};
_queue.Enqueue(asyncresult);
return asyncresult;
}
开发者ID:yk35,项目名称:WpfOpenGLBitmap,代码行数:9,代码来源:MessagingTask.cs
示例17: TransferItem
public TransferItem(byte[] buffer, int offset, int size, AsyncResult asyncResult, DataType type) {
this.Buffer = buffer;
this.Offset = offset;
this.Size = size;
this.AsyncResult = asyncResult;
this.Transferred = 0;
this.Type = type;
this.OriginalSize = size;
}
开发者ID:JnS-Software-LLC,项目名称:iiop-net,代码行数:9,代码来源:TransferItem.cs
示例18: BeginDoTask
// Asynchronous version of time-consuming method (Begin part)
public IAsyncResult BeginDoTask(AsyncCallback callback, Object state)
{
// Create IAsyncResult object identifying the
// asynchronous operation
AsyncResult<DateTime> ar = new AsyncResult<DateTime>(callback, state);
// Use a thread pool thread to perform the operation
ThreadPool.QueueUserWorkItem(DoTaskHelper, ar);
return ar; // Return the IAsyncResult to the caller
}
开发者ID:peteraritchie,项目名称:EffectiveAsyncResult,代码行数:10,代码来源:when_using_async_in_apm_implementation.cs
示例19: AccountSummaryArgument
public AccountSummaryArgument(string tradeDay, string accountIds, string rdlc, AsyncResult asyncResult, long session)
: base(session)
{
this._TradeDay = tradeDay;
this._AccountIds = accountIds;
this._Rdlc = rdlc;
this._AsyncResult = asyncResult;
}
开发者ID:RobertHu,项目名称:TraderServer,代码行数:9,代码来源:AccountSummaryArgument.cs
示例20: WhenCompleted_ThenExecutesCallback
public void WhenCompleted_ThenExecutesCallback()
{
bool executed = false;
var result = new AsyncResult<object>(ar => executed = true, null);
result.SetComplete(null, true);
Assert.IsTrue(executed);
}
开发者ID:eslahi,项目名称:prism,代码行数:9,代码来源:AsyncResultFixture.cs
注:本文中的AsyncResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论