當前位置: 首頁>>代碼示例>>C#>>正文


C# Threading.Dispatcher類代碼示例

本文整理匯總了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;
 }
開發者ID:philippn,項目名稱:now-playing-kiosk,代碼行數:7,代碼來源:MainWindow.xaml.cs

示例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);
 }
開發者ID:qlestrelin,項目名稱:icomierp,代碼行數:7,代碼來源:TaskViewModel.cs

示例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);
 }
開發者ID:ZuTa,項目名稱:StudyingController,代碼行數:7,代碼來源:UserRateListViewModel.cs

示例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.");
            }
        }
開發者ID:Laurent27,項目名稱:IGScalp,代碼行數:26,代碼來源:SmartDispatcher.cs

示例6: CachedBitmap

 public CachedBitmap()
 {
     dispatcher = Dispatcher.CurrentDispatcher;
     _url = "";
     _source = null;
     _workItem = null;
 }
開發者ID:punker76,項目名稱:sjupdater,代碼行數:7,代碼來源:CachedBitmap.cs

示例7: DispatcherSynchronizationContext

		public DispatcherSynchronizationContext (Dispatcher dispatcher)
		{
			if (dispatcher == null)
				throw new ArgumentNullException ("dispatcher");

			this.dispatcher = dispatcher;
		}
開發者ID:dfr0,項目名稱:moon,代碼行數:7,代碼來源:DispatcherSynchronizationContext.cs

示例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");
 }
開發者ID:TestStack,項目名稱:uia-custom-pattern-managed,代碼行數:35,代碼來源:AutomationPeerAugmentationHelper.cs

示例9: DialogManager

		public DialogManager(
			ContentControl parent,
			Dispatcher dispatcher)
		{
			_dispatcher = dispatcher;
			_dialogHost = new DialogLayeringHelper(parent);
		}
開發者ID:tsbrzesny,項目名稱:rma-alzheimer,代碼行數:7,代碼來源:DialogManager.cs

示例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);
        }
開發者ID:jcw-,項目名稱:sparrowtoolkit,代碼行數:29,代碼來源:SparrowInstaller.cs

示例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");
			});
		}
開發者ID:dfr0,項目名稱:moon,代碼行數:27,代碼來源:App.xaml.cs

示例12: FileOpenModalDialog

 internal FileOpenModalDialog(Dispatcher dispatcher, Window parentWindow)
     : base(dispatcher, parentWindow)
 {
     Dialog = new CommonOpenFileDialog { EnsureFileExists = true };
     Filters = new List<FileDialogFilter>();
     FilePaths = new List<string>();
 }
開發者ID:h78hy78yhoi8j,項目名稱:xenko,代碼行數:7,代碼來源:FileOpenModalDialog.cs

示例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
			{
			}
		}
開發者ID:liange,項目名稱:ClaudiaIDE,代碼行數:39,代碼來源:ClaudiaIDE.cs

示例14: CathedraViewModel

        public CathedraViewModel(IUserInterop userInterop, IControllerInterop controllerInterop, Dispatcher dispatcher, CathedraDTO cathedra)
            : base(userInterop, controllerInterop, dispatcher)
        {
            faculties = new List<FacultyDTO>();

            originalEntity = cathedra;
        }
開發者ID:ZuTa,項目名稱:StudyingController,代碼行數:7,代碼來源:CathedraViewModel.cs

示例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();
        }
開發者ID:karthik20522,項目名稱:SimpleDotImage,代碼行數:27,代碼來源:BackgroundDispatcher.cs


注:本文中的System.Windows.Threading.Dispatcher類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。