[英]Observable.fromEventPattern TypedEventHandler
I am able to generate an Observable from HID Input Report events, but I would like to dive in to the packet data with Linq queries. 我能够从HID输入报告事件生成一个Observable,但是我想通过Linq查询来深入研究数据包数据。
I am having trouble making all the types line up. 我在使所有类型排列时遇到麻烦。
readerPackets = Observable
.FromEventPattern
<TypedEventHandler<HidDevice, HidInputReportReceivedEventArgs>,
HidDevice,
HidInputReportReceivedEventArgs>(
h => reader.InputReportReceived += h,
h => reader.InputReportReceived -= h)
.Select(x => x.EventArgs);
This works without the .Select. 在没有.Select的情况下可以使用。 When I add the select I get the error:
当我添加选择时,出现错误:
Cannot implicitly convert type 'System.IObservable<Windows.Devices.HumanInterfaceDevice.HidInputReportReceivedEventArgs>' to 'System.IObservable<System.Reactive.EventPattern<Windows.Devices.HumanInterfaceDevice.HidDevice,Windows.Devices.HumanInterfaceDevice.HidInputReportReceivedEventArgs>>'. An explicit conversion exists (are you missing a cast?)
I have tried casting with the types listed in the error, but apparently I am missing something because I can never make it happy. 我尝试使用错误中列出的类型进行转换,但是显然我缺少了某些东西,因为我永远无法使其满意。
Can you tell what cast type I should use and where it should be placed? 您能告诉我应该使用哪种类型的转换类型以及应该将其放置在什么位置吗?
I found the problem. 我发现了问题。 The compiler highlights the select line as the error.
编译器突出显示选择行作为错误。 The real error was the type of "readerPackets".
真正的错误是“ readerPackets”的类型。 By adjusting that type I was able to make the code functional.
通过调整该类型,我可以使代码起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.