我正在使用反应库,我观察字节,当我得到它们时,我发布它们。我无法找出我应该在哪里等待收集所有字节。然后处理它们。
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
obj.SignatureAvailable.ObserveOn(SynchronizationContext.Current).Subscribe(HandlePinsAvailable);
}
void HandlePinsAvailable(byte[] signBytes)
{
//here I will collect byte blocks.
//MessageBox.Show(Encoding.ASCII.GetString(signBytes));
}
}
public class SignatureListener
{
private Subject<byte[]> SignaturesAvailable = new Subject<byte[]>();
public IObservable<byte[]> SignatureAvailable { get { return SignaturesAvailable.AsObservable(); } }
private IDisposable SignatureSubscription;
public SignatureListener()
{
SignatureSubscription = HidUtility.Messages.Subscribe(HandlePinMessageBytes);
}
public void HandlePinMessageBytes(byte[] signatureBytes)
{
SignaturesAvailable.OnNext(sobj.RawData.ToArray());
}
public class data
{
public void get data()
{
private static Subject<byte[]> subject = new Subject<byte[]>();
public static IObservable<byte[]> Messages { get { return subject.AsObservable(); } }
subject.OnNext(bytes);//I have have the actuall blocks here.
}