<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[James's Programming Page — HidSharp - Catch error when device is unplugged]]></title>
	<link rel="self" href="https://swforum.seekye.com/feed/atom/topic/10083/" />
	<updated>2015-11-13T20:10:27Z</updated>
	<generator>PunBB</generator>
	<id>https://swforum.seekye.com/topic/10083/</id>
		<entry>
			<title type="html"><![CDATA[HidSharp - Catch error when device is unplugged]]></title>
			<link rel="alternate" href="https://swforum.seekye.com/post/12944/#p12944" />
			<content type="html"><![CDATA[<p>I&#039;m using the lib in windows.</p><p>I&#039;m continuously watching the HidStream for data which means that at each callback from BeginRead() I start a new BeginRead().</p><p>That is the way that I found to continuously watch for new inputs.</p><p>The only problem is that when the device is disconnected from the USB port, there is an error that I can&#039;t handle.<br />This error is saved in Exception field of AsyncResult&lt;T&gt; but there are 2 problems there:</p><p>1. - The callback parameter is IAsyncResult, which doesn&#039;t have Exception field.<br />2. - The Exception field in AsyncResult&lt;T&gt; is not public, so I cannot access it anyway.</p><p>I managed to solve by making the field Exception Public and inside the callback handler I do a cast to AsyncResult&lt;T&gt; which I also made public.</p><p>Is that right? Is there any better way to do that? </p><p>Thanks in advance.</p>]]></content>
			<author>
				<name><![CDATA[giovaniluigi]]></name>
				<uri>https://swforum.seekye.com/user/14177/</uri>
			</author>
			<updated>2015-11-13T20:10:27Z</updated>
			<id>https://swforum.seekye.com/post/12944/#p12944</id>
		</entry>
</feed>
