本文整理汇总了C#中System.ComponentModel.AsyncOperation类的典型用法代码示例。如果您正苦于以下问题:C# AsyncOperation类的具体用法?C# AsyncOperation怎么用?C# AsyncOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AsyncOperation类属于System.ComponentModel命名空间,在下文中一共展示了AsyncOperation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IrcClient
public IrcClient(string Server, int Port, string ServerPassword)
{
ops = AsyncOperationManager.CreateOperation(null);
_server = Server;
_port = Port;
_serverPass = ServerPassword;
}
示例2: CalculateAsync
public void CalculateAsync()
{
if (task_id != Guid.Empty)
{
throw new InvalidOperationException();
}
task_id = Guid.NewGuid();
async_operation = AsyncOperationManager.CreateOperation(task_id);
Action calc = () =>
{
Exception error = null;
try
{
CalculatePrimeNumbers();
}
catch (Exception ex)
{
error = ex;
}
bool cancelled = IsTaskCanceled;
bool lock_taken = false;
spin_lock_task_id.Enter(ref lock_taken);
task_id = Guid.Empty;
spin_lock_task_id.Exit(false);
async_operation.PostOperationCompleted((arg) =>
{
if (CalculateCompleted != null)
{
CalculateCompleted(this, arg as AsyncCompletedEventArgs);
}
}, new AsyncCompletedEventArgs(error, cancelled, async_operation.UserSuppliedState));
};
this.AsyncResult = calc.BeginInvoke(null, null);
}
示例3: MessageMarkService
public MessageMarkService([NotNull] IServiceProvider provider)
{
if (provider == null)
throw new ArgumentNullException(nameof(provider));
_provider = provider;
_uiAsyncOperation = _provider.GetRequiredService<IUIShell>().CreateUIAsyncOperation();
}
示例4: Run2
public void Run2()
{
somethingHappened += SynchronizationDemo_somethingHappened;
operation = AsyncOperationManager.CreateOperation(null);
Thread workerThread = new Thread(new ThreadStart(DoWork));
workerThread.Start();
Thread.Sleep(2000);
Output("Call end");
}
示例5: loading
private void loading(object obj, AsyncOperation asyncOperation)
{
string[] flist = (string[])obj;
//loading
string res = "ok";
asyncOperation.PostOperationCompleted(new SendOrPostCallback(OnComplete), res);
}
示例6: UIShell
public UIShell(Func<IWin32Window> parentWindowGetter, [NotNull] Action<bool> uiFreezer)
{
if (parentWindowGetter == null)
throw new ArgumentNullException(nameof(parentWindowGetter));
if (uiFreezer == null) throw new ArgumentNullException(nameof(uiFreezer));
_parentWindowGetter = parentWindowGetter;
_uiFreezer = uiFreezer;
_ctorAsyncOperation = AsyncHelper.CreateOperation();
}
示例7: GemixCompiler
public GemixCompiler()
{
_Thread = new Thread(new ParameterizedThreadStart(gemix_compiler));
_Thread.Priority = ThreadPriority.Normal;
_Thread.IsBackground = true;
_OutputCallBack = new SendOrPostCallback(OutputCallBack);
_AsyncOperation = AsyncOperationManager.CreateOperation(null);
}
示例8: CommentInput
/// <summary>
/// 初始化CommentInput类的新实例。
/// </summary>
protected CommentInput()
{
operation = AsyncOperationManager.CreateOperation(Guid.NewGuid());
onComment = new SendOrPostCallback(o =>
{
if (Comment != null)
Comment(this, new CommentEventArgs((string)o));
}
);
}
示例9: Navigator
internal Navigator([NotNull] IServiceProvider serviceProvider)
{
if (serviceProvider == null)
throw new ArgumentNullException("serviceProvider");
_serviceProvider = serviceProvider;
_uiAsyncOperation = _serviceProvider.GetRequiredService<IUIShell>().CreateUIAsyncOperation();
_form = new NavigationDummyForm(_serviceProvider);
_serviceProvider.GetRequiredService<DockManager>().RegisterPersistablePane(_form);
}
示例10: CompletionMethod
private void CompletionMethod(string output, Exception ex, bool cancelled, AsyncOperation asyncOp)
{
lock (userStateDictionary)
{
userStateDictionary.Remove(asyncOp.UserSuppliedState);
}
// results of the operation
asyncOp.PostOperationCompleted(onCompletedDelegate,
new LongTaskCompletedEventArgs(output, ex, cancelled, asyncOp.UserSuppliedState));
}
示例11: AsyncGuessState
public AsyncGuessState(
string phrase,
NetworkSetting networkSetting,
AsyncOperation asyncOperation,
EventHandler<GuessCompletedEventArgs> guessCompletedHandler)
{
this.asyncOperation = asyncOperation;
this.phrase = phrase;
this.networkSetting = networkSetting;
GuessCompleted += guessCompletedHandler;
}
示例12: SyncGroupHelper
public SyncGroupHelper(string groupName, object userState, AsyncOperation asyncOp, SendOrPostCallback progressReporterDelegate)
{
if (groupName == null)
{
throw new ArgumentNullException("groupName");
}
this.groupName = groupName;
this.userState = userState;
this.asyncOperation = asyncOp;
this.progressReporter = progressReporterDelegate;
}
示例13: TestInit
public void TestInit()
{
ManualResetEvent waitHandle = new ManualResetEvent(false);
ThreadPool.QueueUserWorkItem(o =>
{
operation = AsyncOperationManager.CreateOperation(null);
InputProviderManager = new InputProviderManager_Accessor(new Provider());
waitHandle.Set();
Application.Run();
});
waitHandle.WaitOne();
}
示例14: DispatchCompleting
private void DispatchCompleting(MessageData responsemsg, Exception ex, bool canceled, AsyncOperation asyncOper)
{
if (!canceled)
{
lock (_userStateToLifetime.SyncRoot)
{
_userStateToLifetime.Remove(asyncOper.UserSuppliedState);
}
}
TransmitCompletedEventArgs eventArgs = new TransmitCompletedEventArgs(responsemsg, ex, canceled, asyncOper.UserSuppliedState);
asyncOper.PostOperationCompleted(onCompletedDelegate, eventArgs);
}
示例15: Process
protected override Bitmap Process(Bitmap bitmap, AsyncOperation asyncOp)
{
Bitmap newBitmap = new Bitmap(bitmap);
Graphics g = Graphics.FromImage(newBitmap);
g.SmoothingMode = SmoothingMode.HighQuality;
g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
SizeF textSize = g.MeasureString(ImageAddTextPluginContext.Text, ImageAddTextPluginContext.Font);
PointF p = new Point();
switch (ImageAddTextPluginContext.Position)
{
case ContentAlignment.TopLeft:
p.X = 0.0f;
p.Y = 0.0f;
break;
case ContentAlignment.TopCenter:
p.X = (newBitmap.Width - textSize.Width) / 2;
p.Y = 0.0f;
break;
case ContentAlignment.TopRight:
p.X = newBitmap.Width - textSize.Width;
p.Y = 0.0f;
break;
case ContentAlignment.MiddleLeft:
p.X = 0.0f;
p.Y = (newBitmap.Height - textSize.Height) / 2;
break;
case ContentAlignment.MiddleCenter:
p.X = (newBitmap.Width - textSize.Width) / 2;
p.Y = (newBitmap.Height - textSize.Height) / 2;
break;
case ContentAlignment.MiddleRight:
p.X = newBitmap.Width - textSize.Width;
p.Y = (newBitmap.Height - textSize.Height) / 2;
break;
case ContentAlignment.BottomLeft:
p.X = 0.0f;
p.Y = newBitmap.Height - textSize.Height;
break;
case ContentAlignment.BottomCenter:
p.X = (newBitmap.Width - textSize.Width) / 2;
p.Y = newBitmap.Height - textSize.Height;
break;
case ContentAlignment.BottomRight:
p.X = newBitmap.Width - textSize.Width;
p.Y = newBitmap.Height - textSize.Height;
break;
}
p.X += ImageAddTextPluginContext.XOffset;
p.Y += ImageAddTextPluginContext.YOffset;
g.DrawString(ImageAddTextPluginContext.Text, ImageAddTextPluginContext.Font, new SolidBrush(ImageAddTextPluginContext.Color), p);
g.Dispose();
return newBitmap;
}