本文整理汇总了C#中System.Windows.Threading.Dispatcher类的典型用法代码示例。如果您正苦于以下问题:C# Dispatcher类的具体用法?C# Dispatcher怎么用?C# Dispatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Dispatcher类属于System.Windows.Threading命名空间,在下文中一共展示了Dispatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TrackInfoPoller
public TrackInfoPoller(NowPlayingTrackInfoProvider Provider, CoverManager CoverManager, Window window)
{
this.nowPlayingProvider = Provider;
this.coverManager = CoverManager;
this.window = window;
this.dispatcher = App.Current.Dispatcher;
}
示例2: TaskViewModel
public TaskViewModel(Dispatcher disp)
{
this._dispatcher = disp;
AnnulerCommand = new GenericCommand<object>(ExecuteAnnulerCommand, CanExecuteAnnulerCommand);
EffectuerCommand = new GenericCommand<object>(ExecuteEffectuerCommand, CanExecuteEffectuerCommand);
DeclarerProbleme = new GenericCommand<object>(ExecuteDeclarerProblemeCommand, CanExecuteDeclarerProblemeCommand);
}
示例3: UserRateListViewModel
public UserRateListViewModel(IUserInterop userInterop, IControllerInterop controllerInterop, Dispatcher dispatcher, BaseEntityDTO entity)
: base(userInterop, controllerInterop, dispatcher)
{
this.entity = entity;
rates = new ObservableCollection<UserRateItemDTO>();
Rates = new ReadOnlyObservableCollection<UserRateItemDTO>(rates);
}
示例4: MainViewModel
public MainViewModel()
{
_Dispatcher = Dispatcher.CurrentDispatcher;
Items = new ObservableCollection<string>();
Items.Add("Messages go here");
}
开发者ID:modulexcite,项目名称:MEF-Plugin-With-Custom-Attributes-and-Metadata-Sample,代码行数:7,代码来源:MainViewModel.cs
示例5: RequireInstance
private static void RequireInstance()
{
// Design-time is more of a no-op, won't be able to resolve the
// dispatcher if it isn't already set in these situations.
if (_designer || Application.Current == null)
{
return;
}
// Attempt to use the RootVisual of the plugin to retrieve a
// dispatcher instance. This call will only succeed if the current
// thread is the UI thread.
try
{
_instance = Application.Current.Dispatcher;
}
catch (Exception e)
{
throw new InvalidOperationException("The first time SmartDispatcher is used must be from a user interface thread. Consider having the application call Initialize, with or without an instance.", e);
}
if (_instance == null)
{
throw new InvalidOperationException("Unable to find a suitable Dispatcher instance.");
}
}
示例6: CachedBitmap
public CachedBitmap()
{
dispatcher = Dispatcher.CurrentDispatcher;
_url = "";
_source = null;
_workItem = null;
}
示例7: DispatcherSynchronizationContext
public DispatcherSynchronizationContext (Dispatcher dispatcher)
{
if (dispatcher == null)
throw new ArgumentNullException ("dispatcher");
this.dispatcher = dispatcher;
}
示例8: GuardUiaServerInvocation
private static void GuardUiaServerInvocation(Action invocation, Dispatcher dispatcher)
{
if (dispatcher == null)
throw new ElementNotAvailableException();
Exception remoteException = null;
bool completed = false;
dispatcher.Invoke(DispatcherPriority.Send, TimeSpan.FromMinutes(3.0), (Action)(() =>
{
try
{
invocation();
}
catch (Exception e)
{
remoteException = e;
}
catch
{
remoteException = null;
}
finally
{
completed = true;
}
}));
if (completed)
{
if (remoteException != null)
throw remoteException;
}
else if (dispatcher.HasShutdownStarted)
throw new InvalidOperationException("AutomationDispatcherShutdown");
else
throw new TimeoutException("AutomationTimeout");
}
示例9: DialogManager
public DialogManager(
ContentControl parent,
Dispatcher dispatcher)
{
_dispatcher = dispatcher;
_dialogHost = new DialogLayeringHelper(parent);
}
示例10: Run
protected override void Run()
{
this.Engine.Log(LogLevel.Verbose, "Launching Sparrow.Chart.Installer");
BootstrapperDispatcher = Dispatcher.CurrentDispatcher;
MainViewModel viewModel = new MainViewModel(this);
viewModel.Bootstrapper.Engine.Detect();
if (viewModel.Bootstrapper.Command.Action == LaunchAction.Install && !isInstalled)
{
MainView view = new MainView();
view.DataContext = viewModel;
view.Closed += (sender, e) => BootstrapperDispatcher.InvokeShutdown();
view.Show();
isInstalled = true;
}
if (viewModel.Bootstrapper.Command.Action == LaunchAction.Uninstall && !isUninstalled)
{
MainView view = new MainView();
view.DataContext = viewModel;
view.Closed += (sender, e) => BootstrapperDispatcher.InvokeShutdown();
view.Show();
isUninstalled = true;
}
Dispatcher.Run();
this.Engine.Quit(0);
}
示例11: Application_Startup
private void Application_Startup (object sender, StartupEventArgs e)
{
Panel root = new TestElement { Name = "Root" };
root.Children.Add (CreateTemplated ("Button1"));
d = root.Dispatcher;
RootVisual = root;
Delay (() => {
Console.WriteLine ("Actual");
Console.Write (sb.ToString ());
Console.WriteLine ();
Console.WriteLine ();
Console.WriteLine (@"Expected
Button1: Loaded
Root: Loaded
Button2: Loaded
Button1: OnApplyTemplate
Button1: MeasureOverride
Button2: OnApplyTemplate
Button2: MeasureOverride
Button1: ArrangeOverride
Button2: ArrangeOverride
Root: LayoutUpdated
Button1: LayoutUpdated
Button2: LayoutUpdated");
});
}
示例12: FileOpenModalDialog
internal FileOpenModalDialog(Dispatcher dispatcher, Window parentWindow)
: base(dispatcher, parentWindow)
{
Dialog = new CommonOpenFileDialog { EnsureFileExists = true };
Filters = new List<FileDialogFilter>();
FilePaths = new List<string>();
}
示例13: ClaudiaIDE
/// <summary>
/// Creates a square image and attaches an event handler to the layout changed event that
/// adds the the square in the upper right-hand corner of the TextView via the adornment layer
/// </summary>
/// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
/// <param name="imageProvider">The <see cref="IImageProvider"/> which provides bitmaps to draw</param>
/// <param name="setting">The <see cref="Setting"/> contains user image preferences</param>
public ClaudiaIDE(IWpfTextView view, List<IImageProvider> imageProvider, Setting setting)
{
try
{
_dispacher = Dispatcher.CurrentDispatcher;
_imageProviders = imageProvider;
_imageProvider = imageProvider.FirstOrDefault(x=>x.ProviderType == setting.ImageBackgroundType);
_setting = setting;
if (_imageProvider == null)
{
_imageProvider = new SingleImageProvider(_setting);
}
_view = view;
_image = new Image
{
Opacity = setting.Opacity,
IsHitTestVisible = false
};
_adornmentLayer = view.GetAdornmentLayer("ClaudiaIDE");
_view.ViewportHeightChanged += delegate { RepositionImage(); };
_view.ViewportWidthChanged += delegate { RepositionImage(); };
_view.ViewportLeftChanged += delegate { RepositionImage(); };
_setting.OnChanged += delegate { ReloadSettings(); };
_imageProviders.ForEach(x => x.NewImageAvaliable += delegate { InvokeChangeImage(); });
ChangeImage();
}
catch
{
}
}
示例14: CathedraViewModel
public CathedraViewModel(IUserInterop userInterop, IControllerInterop controllerInterop, Dispatcher dispatcher, CathedraDTO cathedra)
: base(userInterop, controllerInterop, dispatcher)
{
faculties = new List<FacultyDTO>();
originalEntity = cathedra;
}
示例15: BackgroundDispatcher
public BackgroundDispatcher(string name)
{
AutoResetEvent are = new AutoResetEvent(false);
Thread thread = new Thread((ThreadStart)delegate
{
_dispatcher = Dispatcher.CurrentDispatcher;
_dispatcher.UnhandledException +=
delegate(
object sender,
DispatcherUnhandledExceptionEventArgs e)
{
e.Handled = true;
};
are.Set();
Dispatcher.Run();
});
thread.Name = string.Format("BackgroundStaDispatcher({0})", name);
thread.SetApartmentState(ApartmentState.MTA);
thread.IsBackground = true;
thread.Start();
are.WaitOne();
are.Close();
are.Dispose();
}