I’m trying to follow the Win SDK documentation, but its too sparse for me to follow (my c#-fu is weak).
I have my windows Form app successfully logging in, retrieving my device list and their published variables, and I can send data to my devices - but i can’t figure out how to subscribe to the event stream.
If I copy the example code :
private void onEvent(object sender, ParticleEventResponse particeEvent)
{
Debug.WriteLine($"Got Event {particeEvent.Name} with data {particeEvent.Data}");
}
Guid eventListenerID = ParticleCloud.SharedCloud.SubscribeToAllEventsWithPrefixAsync(onEvent, "temp");
Visual Studio complains about the last line:
Error CS0236 A field initializer cannot reference the non-static field, method, or property 'Form1.onEvent(object, ParticleEventResponse)' WGcontrol C:\Users\paul\documents\visual studio 2015\Projects\WGcontrol\WGcontrol\Form1.cs
What am I doing wrong? I’m putting the code in Form.cs - is that the right place?
Also what is this?
ParticleCloud.SharedCloud.SynchronizationContext = System.Threading.SynchronizationContext.Current;
Do I need it? Where do I put it?