本文整理汇总了C#中System.Windows.Threading.Dispatcher.Run方法的典型用法代码示例。如果您正苦于以下问题:C# Dispatcher.Run方法的具体用法?C# Dispatcher.Run怎么用?C# Dispatcher.Run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Threading.Dispatcher
的用法示例。
在下文中一共展示了Dispatcher.Run方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAndShowContent
private void CreateAndShowContent()
{
Dispatcher = Dispatcher.CurrentDispatcher;
VisualTargetPresentationSource source = new VisualTargetPresentationSource(_hostVisual);
_resetEvent.Set();
source.RootVisual = _createContent();
DesiredSize = source.DesiredSize;
_invalidateMeasure();
Dispatcher.Run();
source.Dispose();
}
示例2: Main
static void Main(string[] args)
{
if (args.Length != 1)
{
Console.Error.WriteLine("Usage: PluginHost name");
return;
}
try
{
Console.WriteLine("Host starting: ARGS: " + args[0]);
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload;
var name = args[0];
int bits = IntPtr.Size * 8;
Console.WriteLine("Starting PluginHost {0}, {1} bit", name, bits );
Dispatcher = Dispatcher.CurrentDispatcher;
var serverProvider = new BinaryServerFormatterSinkProvider { TypeFilterLevel = TypeFilterLevel.Full };
var clientProvider = new BinaryClientFormatterSinkProvider();
var properties = new Hashtable();
properties["portName"] = name;
var channel = new IpcChannel(properties, clientProvider, serverProvider);
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(PluginLoader), "PluginLoader", WellKnownObjectMode.Singleton);
SignalReady(name);
Dispatcher.Run();
}
catch (Exception ex)
{
ShowException(ex);
}
Console.ReadKey();
}
示例3: Run
/// <summary>
/// Thread entry point for WiX Toolset UX.
/// </summary>
protected override void Run()
{
Engine.Log(LogLevel.Verbose, "Running the ESME Bootstrapper.");
Model = new Model(this);
Dispatcher = Dispatcher.CurrentDispatcher;
var backgroundColorString = Engine.StringVariables["BackgroundColor"];
var progressBarColorString = Engine.StringVariables["ProgressBarColor"];
var convertedBackgroundColorObject = ColorConverter.ConvertFromString(backgroundColorString);
var convertedProgressBarColorObject = ColorConverter.ConvertFromString(progressBarColorString);
var backgroundColor = (Color)(convertedBackgroundColorObject ?? Colors.LightSeaGreen);
var progressBarColor = (Color)(convertedProgressBarColorObject ?? Color.FromArgb(0xFF, 0x00, 0x8E, 0x91));
var viewModel = new RootViewModel
{
BundleLongName = Engine.StringVariables["BundleLongName"],
BundleShortName = Engine.StringVariables["BundleShortName"],
ProductLongName = Engine.StringVariables["ProductLongName"],
ProductShortName = Engine.StringVariables["ProductShortName"],
ProductFullVersion = Engine.StringVariables["ProductFullVersion"],
ButtonBackgroundBrush = new SolidColorBrush(backgroundColor),
ProgressBarBrush = new SolidColorBrush(progressBarColor),
};
// Populate the view models with the latest data. This is where Detect is called.
viewModel.Refresh();
// Create a Window to show UI.
if (Model.Command.Display == Display.Passive ||
Model.Command.Display == Display.Full)
{
Engine.Log(LogLevel.Verbose, "Creating a UI.");
View = new RootView(viewModel);
View.Show();
}
Dispatcher.Run();
Engine.Quit(0);
}
示例4: StartDispatcher
public void StartDispatcher()
{
this.Dispatcher = null;
_thread = new Thread(() =>
{
this.Dispatcher = Dispatcher.CurrentDispatcher;
Dispatcher.Run();
});
_thread.SetApartmentState(ApartmentState.STA);
_thread.IsBackground = true;
_thread.Start();
while (this.Dispatcher == null) //waitinig while dispatcher starts
Thread.Sleep(1);
}
示例5: CreateAndShowContent
private void CreateAndShowContent()
{
this.Dispatcher = Dispatcher.CurrentDispatcher;
var source = new VisualTargetPresentationSource( _hostVisual );
this._sync.Set();
source.RootVisual = _createContent();
this.DesiredSize = source.DesiredSize;
this._invalidateMeasure();
Dispatcher.Run();
source.Dispose();
}
示例6: _CreateAndShowContent
/// <summary>
/// Creates and show content.
/// </summary>
private void _CreateAndShowContent()
{
Dispatcher = Dispatcher.CurrentDispatcher;
var source = new VisualTargetPresentationSource(_hostVisual);
_sync.Set();
source.RootVisual = _createContent();
DesiredSize = source.DesiredSize;
_rootVisual = source.RootVisual as Control;
Debug.Assert(null != _rootVisual);
_invalidateMeasure();
Dispatcher.Run();
source.Dispose();
}