本文整理汇总了C#中System.Windows.Threading.Dispatcher.BeginInvoke方法的典型用法代码示例。如果您正苦于以下问题:C# Dispatcher.BeginInvoke方法的具体用法?C# Dispatcher.BeginInvoke怎么用?C# Dispatcher.BeginInvoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Threading.Dispatcher
的用法示例。
在下文中一共展示了Dispatcher.BeginInvoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Verify
public static bool Verify(Dispatcher dispatcher, Stream file)
{
if (file.Length == 0)
{
dispatcher.BeginInvoke(() =>
MessageBox.Show(Resources.EmptyFile,
Properties.Resources.DownloadTitle,
MessageBoxButton.OK));
return false;
}
if (!DatabaseReader.CheckSignature(file))
{
dispatcher.BeginInvoke(() =>
MessageBox.Show(Resources.NotKdbx,
Properties.Resources.DownloadTitle,
MessageBoxButton.OK));
return false;
}
file.Position = 0;
return true;
}
示例2: Refresh
internal void Refresh(Dispatcher dispatcher)
{
dispatcher.BeginInvoke((Action)delegate
{
//RGB
unsafe
{
if (rgbSource != null)
{
ReadLockedWrapperPtr ptr = ResultsDllWrapper.lockFactoryImage(ImageProductType.RGBSourceProduct);
rgbSource.Lock();
rgbSource.WritePixels(new Int32Rect(0, 0, rgbWidth, rgbHeight), ptr.IntPtr, rgbWidth * rgbHeight * 3, rgbWidth * 3);
rgbSource.Unlock();
ResultsDllWrapper.releaseReadLockedWrapperPtr(ptr);
}
}
//Depth
unsafe
{
if (depthSource != null)
{
ReadLockedWrapperPtr ptr = ResultsDllWrapper.lockFactoryImage(ImageProductType.DepthSynchronizedProduct);
depthSource.Lock();
depthSource.WritePixels(new Int32Rect(0, 0, depthWidth, depthHeight), ptr.IntPtr, depthWidth * depthHeight * 2, depthWidth * 2);
depthSource.Unlock();
ResultsDllWrapper.releaseReadLockedWrapperPtr(ptr);
}
}
}, null);
}
示例3: BeginInvoke
public static void BeginInvoke(Dispatcher dispatcher, Action action)
{
if (IsSynchronous)
action();
else
dispatcher.BeginInvoke(action);
}
示例4: FacebookWPFBrowser
/// <summary>
/// Constructor
/// </summary>
/// <param name="url">The url to navigate to when loaded.</param>
public FacebookWPFBrowser(string url)
{
dispatcher = Dispatcher.CurrentDispatcher;
InitializeComponent();
_url = url;
dispatcher.BeginInvoke(new Action(() => this.webBrowser.Navigate(new Uri(_url))));
}
开发者ID:jeffdeville,项目名称:FacebookDeveloperToolkit---Fork-at-37335,代码行数:11,代码来源:FacebookWPFBrowser.xaml.cs
示例5: VisualCommentsHelper
public VisualCommentsHelper(Dispatcher disp, ItemContainerGenerator gen, Comment placeholder)
{
_gen = gen;
_placeholder = placeholder;
disp.BeginInvoke(new Action(DeferredFocusSet),
System.Windows.Threading.DispatcherPriority.Background, null);
}
示例6: ExecuteAsyncUI
public static void ExecuteAsyncUI(Dispatcher dispatcher, Action action, Action callback)
{
DispatcherOperation dispatcherOp = dispatcher.BeginInvoke(action, DispatcherPriority.Normal);
if (null != callback)
{
dispatcherOp.Completed += (s, e) => { callback(); };
}
}
示例7: DoEvents
public static void DoEvents(Dispatcher disp = null) {
DispatcherFrame frame = new DispatcherFrame();
if(disp == null) {
disp = Dispatcher.CurrentDispatcher;
}
disp.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(ExitFrame), frame);
Dispatcher.PushFrame(frame);
}
示例8: CommentNotificationDeferral
public CommentNotificationDeferral(Dispatcher disp, DiscCtx ctx, ItemsControl commentItems)
{
_disp = disp;
_ctx = ctx;
_commentItems = commentItems;
_disp.BeginInvoke(new Action(InjectCommentNotifications),
System.Windows.Threading.DispatcherPriority.Background);
}
示例9: WithExceptionThrowingInDispatcher
/// <summary>
/// Rethrows exceptions thrown during task execution in thespecified dispatcher thread.
/// </summary>
/// <param name="task">The task.</param>
/// <param name="dispatcher">The dispatcher.</param>
/// <returns></returns>
public static Task WithExceptionThrowingInDispatcher(this Task task, Dispatcher dispatcher)
{
return task.ContinueWith(t =>
{
dispatcher.BeginInvoke(() =>
{
throw t.Exception;
}, DispatcherPriority.Send);
}, TaskContinuationOptions.OnlyOnFaulted);
}
示例10: CreateTournamentViewModel
public CreateTournamentViewModel(Dispatcher dispatcher)
{
_dispatcher = dispatcher;
_xmppHost = ((App)App.Current).XmppHost;
_gameController = ServiceLocator.Current.GetInstance<GameController>();
StartTournamentCommand = new RelayCommand(StartTournament);
TournamentTypeListInternal.Add(new Option<string>("Round Robin", "RoundRobin"));
_xmppHost.PlayerRegistered += (sender, e) => { _dispatcher.BeginInvoke(() => { RegisteredPlayerListInternal.Add(new Option<Jid>(e.User.Bare, e.User)); UpdateCanStartTournament(); }); };
}
示例11: GitHubModel
public GitHubModel(Dispatcher dispatcher)
{
Dispatcher = dispatcher;
_exceptionAction = ex => Dispatcher.BeginInvoke(() =>
MessageBox.Show("Error: " + Enum.GetName(typeof(ErrorType), ex.ErrorType), "", MessageBoxButton.OK)
);
_client = new GitHubClient();
Contexts = new ObservableCollection<Context>();
}
示例12: OnUiThread
public static void OnUiThread(Action action, Dispatcher disp = null,
DispatcherPriority prio = DispatcherPriority.Background)
{
if (disp == null)
{
if (Application.Current != null)
disp = Application.Current.Dispatcher;
}
if (disp != null)
disp.BeginInvoke(action, prio);
}
示例13: BuildItemViewModel
public BuildItemViewModel(BuildItem item, Dispatcher dispatcher)
{
Item = item;
Item.StatusChanged += (sender, args) => dispatcher.BeginInvoke((Action)(() =>
{
NotifyPropertyChanged("Status");
NotifyPropertyChanged("Error");
NotifyPropertyChanged("ErrorTitle");
NotifyPropertyChanged("ErrorMessage");
NotifyPropertyChanged("ShowError");
}));
}
示例14: UpdateStats
private void UpdateStats(RoutedEventArgs e)
{
var button = e.Source as Button;
if (button != null)
{
_dispatcher = button.Dispatcher;
var client = BrightstarService.GetClient(Store.Source.ConnectionString);
_statsUpdateJob = client.UpdateStatistics(Store.Location);
_dispatcher.BeginInvoke(DispatcherPriority.SystemIdle,
new TransactionViewModel.JobMonitorDelegate(CheckJobStatus));
}
}
示例15: Download
public void Download(string file, string saveWhere, Dispatcher dispatch, Action done)
{
var shareResp = _client.GetMedia(file);
using (WebClient webclient = new WebClient())
{
webclient.DownloadFileCompleted +=
(object sender, AsyncCompletedEventArgs e) =>
{ dispatch.BeginInvoke(new Action(() => { done(); })); };
webclient.DownloadFileAsync(new Uri(shareResp.Url), saveWhere);
}
}