コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="stateInfo"></param>
        private void Initialize(object stateInfo)
        {
            _stopping = false;
            bool success = false;

            try
            {
                _deviceEnumerator.RegisterEndpointNotificationCallback(this);
                success = true;
            }
            catch { }

            if (!success)
            {
                _deviceEnumerator = new MMDeviceEnumerator();
                _deviceEnumerator.RegisterEndpointNotificationCallback(this);
            }

            foreach (var device in _deviceEnumerator.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active))
            {
                OnDeviceAdded(device);
            }

            foreach (var device in _devices.Values)
            {
                if (device.IsDefault)
                {
                    OnDefaultDeviceChanged(device);
                }
            }

            _synchronizationContext.Post(o => ServiceStarted?.Invoke(this), null);
        }
コード例 #2
0
ファイル: ConcurrentService.cs プロジェクト: unixcrh/win-app
        private async Task <Result> StartAction(CancellationToken cancellationToken)
        {
            var result = await _origin.StartAsync(cancellationToken);

            if (result.Success)
            {
                ServiceStarted?.Invoke(this, _origin.Name);
            }

            return(result);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="stateInfo"></param>
        private void Initialize(object stateInfo)
        {
            _stopping = false;
            _deviceEnumerator.DeviceAdded        += OnDeviceAdded;
            _deviceEnumerator.DeviceStateChanged += OnDeviceStateChanged;

            foreach (var device in _deviceEnumerator.EnumAudioEndpoints(DataFlow.All, DeviceState.Active))
            {
                OnDeviceAdded(device);
            }

            foreach (var device in _devices.Values)
            {
                if (device.IsDefault)
                {
                    OnDefaultDeviceChanged(device);
                }
            }

            _synchronizationContext.Post(o => ServiceStarted?.Invoke(this), null);
        }
コード例 #4
0
 protected virtual void OnServiceStarted()
 {
     ServiceStarted?.Invoke(this, null);
 }