Skip to content

Commit

Permalink
Default regist the MonitorDeviceEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
flier268 committed Jun 10, 2020
1 parent c053537 commit 7a43351
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
12 changes: 6 additions & 6 deletions UsbHid.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
Expand All @@ -10,17 +10,17 @@
<PackageLicenseExpression></PackageLicenseExpression>
<Authors />
<Company />
<Version>1.2.0</Version>
<AssemblyVersion>1.2.0.0</AssemblyVersion>
<FileVersion>1.2.0.0</FileVersion>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Version>1.2.1</Version>
<AssemblyVersion>1.2.1.0</AssemblyVersion>
<FileVersion>1.2.1.0</FileVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseFile>licence.md</PackageLicenseFile>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<Optimize>false</Optimize>
<DefineConstants>DEBUG</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>

<ItemGroup>
Expand Down
9 changes: 7 additions & 2 deletions UsbHidDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ public bool MonitorDeviceEvents
#endregion

#region Construction

public UsbHidDevice(string devicePath)
/// <summary>
/// Create HID connection
/// </summary>
/// <param name="devicePath">Device Path(could got it from<code>DeviceDiscovery.FindHidDevices(new VidPidMatcher(VID, PID))</code></param>
/// <param name="MonitorDeviceEvents">Regist Connected/Disconnected event</param>
public UsbHidDevice(string devicePath, bool MonitorDeviceEvents = true)
{
_deviceInformation.DevicePathName = devicePath;
_worker = new BackgroundWorker();
Expand All @@ -86,6 +90,7 @@ public UsbHidDevice(string devicePath)
_deviceEventMonitor = new HidDeviceEventMonitor(this);
_deviceEventMonitor.Connected += ReportConnected;
_deviceEventMonitor.Disconnected += ReportDisConnected;
this.MonitorDeviceEvents = MonitorDeviceEvents;
}

~UsbHidDevice()
Expand Down

0 comments on commit 7a43351

Please sign in to comment.