Ejemplo n.º 1
0
    /// <summary>
    /// Stops listening for messages from the device.
    /// </summary>
    void StopDevice()
    {
      try
      {
        lock (_startStopLock)
        {
          if (_notifyWindow != null)
          {
            _notifyWindow.DeviceArrival -= OnDeviceArrival;
            _notifyWindow.DeviceRemoval -= OnDeviceRemoval;
          }

          StopReadThread();
          CloseDevice();
        }
      }
      catch (Exception ex)
      {
        DebugWriteLine(ex.ToString());
        throw;
      }
      finally
      {
        if (_notifyWindow != null)
        {
          _notifyWindow.UnregisterDeviceArrival();
          _notifyWindow.Dispose();
          _notifyWindow = null;
        }
      }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Starts listening for messages from the device.
    /// </summary>
    void StartDevice()
    {
      lock (_startStopLock)
      {
        _notifyWindow = new NotifyWindow();
        _notifyWindow.Create();
        _notifyWindow.Class = _deviceGuid;
        _notifyWindow.RegisterDeviceArrival();

        OpenDevice();
        InitializeDevice();

        StartReadThread(ReadThreadMode.Receiving);

        _notifyWindow.DeviceArrival += OnDeviceArrival;
        _notifyWindow.DeviceRemoval += OnDeviceRemoval;
      }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Stop access to the device.
    /// </summary>
    public override void Stop()
    {
      DebugWriteLine("Stop()");

      try
      {
        _notifyWindow.DeviceArrival -= OnDeviceArrival;
        _notifyWindow.DeviceRemoval -= OnDeviceRemoval;

        StopReadThread();
        CloseDevice();
      }
      catch (Exception ex)
      {
        DebugWriteLine(ex.ToString());
        throw;
      }
      finally
      {
        _notifyWindow.UnregisterDeviceArrival();
        _notifyWindow.Dispose();
        _notifyWindow = null;

        DebugClose();
      }
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Start using the device.
    /// </summary>
    public override void Start()
    {
      try
      {
        DebugOpen("MicrosoftMceTransceiver_DriverVista.log");
        DebugWriteLine("Start()");
        DebugWriteLine("Device Guid: {0}", _deviceGuid);
        DebugWriteLine("Device Path: {0}", _devicePath);

        _isSystem64Bit = IrssUtils.Win32.Check64Bit();
        DebugWriteLine("Operating system arch is {0}", _isSystem64Bit ? "x64" : "x86");

        _notifyWindow = new NotifyWindow();
        _notifyWindow.Create();
        _notifyWindow.Class = _deviceGuid;
        //_notifyWindow.RegisterDeviceArrival();

        OpenDevice();
        InitializeDevice();

        StartReadThread(ReadThreadMode.Receiving);

        _notifyWindow.DeviceArrival += OnDeviceArrival;
        _notifyWindow.DeviceRemoval += OnDeviceRemoval;
      }
      catch
      {
        DebugClose();
        throw;
      }
    }
    /// <summary>
    /// Stop access to the device.
    /// </summary>
    public override void Stop()
    {
      DebugWriteLine("Stop()");

      try
      {
        if (_readHandle == null)
          throw new InvalidOperationException("Cannot stop, device is not active");

        _notifyWindow.DeviceArrival -= OnDeviceArrival;
        _notifyWindow.DeviceRemoval -= OnDeviceRemoval;

        WriteSync(StopPacket);
        StopReadThread();
        CloseDevice();
      }
      catch (Exception ex)
      {
        DebugWriteLine(ex.ToString());
        throw;
      }
      finally
      {
        _notifyWindow.UnregisterDeviceArrival();
        _notifyWindow.Dispose();
        _notifyWindow = null;

        DebugClose();
      }
    }
    /// <summary>
    /// Start using the device.
    /// </summary>
    public override void Start()
    {
      try
      {
        DebugOpen("MicrosoftMceTransceiver_DriverReplacement.log");
        DebugWriteLine("Start()");
        DebugWriteLine("Device Guid: {0}", _deviceGuid);
        DebugWriteLine("Device Path: {0}", _devicePath);
        DebugWriteLine("Device Type: {0}", Enum.GetName(typeof (DeviceType), _deviceType));

        _notifyWindow = new NotifyWindow();
        _notifyWindow.Create();
        _notifyWindow.Class = _deviceGuid;
        _notifyWindow.RegisterDeviceArrival();

        OpenDevice();
        StartReadThread();
        InitializeDevice();

        _notifyWindow.DeviceArrival += OnDeviceArrival;
        _notifyWindow.DeviceRemoval += OnDeviceRemoval;
      }
      catch
      {
        DebugClose();
        throw;
      }
    }