Exemplo n.º 1
0
        /// <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();
        }
Exemplo n.º 2
0
		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;			
		}
Exemplo n.º 3
0
		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 ();
			}
		}