是否可以中止/取消 FileStream.Beginread 异步读取操作
我想使用 USB 接口控制 STM32 微控制器。简·阿克塞尔森 (http://www.lvr.com/hidpage.htm#MyExampleCode)创建了一些应用程序来展示 USB HID 类的用法,该类现在是我的基础源。
为了检查我的设备是否有一些待处理的数据,我创建了一个调用 Filestream.BeginRead()
例程的线程。现在我想中止/取消这个请求,因为退出该线程后它仍然是打开/阻塞的(设置一个变量来取消线程循环)。所以我想知道如何执行取消此 BeginRead()
调用。或者您有更好的想法如何检查USB设备连续发送的数据吗?
// USB read data from device thread
while (boRunThread)
{
if (boStopThread)
{
// perform clean-up, cancel BeginRead
// ... Abort(ar)???
}
if (botransfer == false)
{
botransfer = true; // Signal pending transfer
ar = fileStreamDeviceData.BeginRead(inputReportBuffer, 0, inputReportBuffer.Length, callb, inputReportBuffer);
}
}
I want to control a STM32 microcontroller using the USB interface. Jan Axelson (http://www.lvr.com/hidpage.htm#MyExampleCode) has created some applications to show the usage of the USB HID class which is now my base source.
To check if my device has some pending data I have created a thread calling the Filestream.BeginRead()
routine. Now I want to abort/cancel this request, because it is still open/blocked after exiting that thread (setting a variable to cancel the thread loop). So I am wondering how to perform a cancellation this BeginRead()
call. Or do you have a better idea how to check for continuous sent data of the USB device?
// USB read data from device thread
while (boRunThread)
{
if (boStopThread)
{
// perform clean-up, cancel BeginRead
// ... Abort(ar)???
}
if (botransfer == false)
{
botransfer = true; // Signal pending transfer
ar = fileStreamDeviceData.BeginRead(inputReportBuffer, 0, inputReportBuffer.Length, callb, inputReportBuffer);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论