本文整理汇总了C#中System.Threading.SynchronizationContext.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# SynchronizationContext.GetType方法的具体用法?C# SynchronizationContext.GetType怎么用?C# SynchronizationContext.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Threading.SynchronizationContext
的用法示例。
在下文中一共展示了SynchronizationContext.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WaveOutEvent
/// <summary>
/// Opens a WaveOut device
/// </summary>
public WaveOutEvent()
{
syncContext = SynchronizationContext.Current;
if (syncContext != null &&
((syncContext.GetType().Name == "LegacyAspNetSynchronizationContext") ||
(syncContext.GetType().Name == "AspNetSynchronizationContext")))
{
syncContext = null;
}
// set default values up
DeviceNumber = 0;
DesiredLatency = 300;
NumberOfBuffers = 2;
this.waveOutLock = new object();
}
示例2: InitializeApartmentDetails
private void InitializeApartmentDetails ()
{
// Only synchronization_context if thread is STA.
if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
return;
synchronization_context = SynchronizationContext.Current;
// Check whether the current context is a plain SynchronizationContext object
// and handle this as if no context was set at all.
if (synchronization_context != null &&
synchronization_context.GetType () == typeof(SynchronizationContext))
synchronization_context = null;
}
示例3: StartInitialization
internal void StartInitialization ()
{
// Store the main sync context, since we'll need later on for subscribing
// add-in extension points (Mono.Addins isn't currently thread safe)
mainContext = SynchronizationContext.Current;
// If there is no custom threading context, we can't use background initialization since
// we have no main thread into which to dispatch
backgroundInitialize = mainContext != null && mainContext.GetType () != typeof (SynchronizationContext);
if (backgroundInitialize) {
// Initialize the service in a background thread.
initializing = true;
Thread t = new Thread (new ThreadStart (BackgroundInitialize)) {
Name = "Assembly service initialization",
IsBackground = true,
};
t.Start ();
}
}