private static void loggedOut(LoggedOutMessage mes)
 {
     var y = yourEvents;
     yourEvents = null;
     if (y != null)
     {
         y.Events -= YourEvents_Events; // clean up the listener
         y.Stop();
         y = null;
     }
 }
 private static void loggedIn(LoggedInMessage mes)
 {
     if(yourEvents != null)
     {
         loggedOut(new LoggedOutMessage()); // loggedOut will clean up the previous instance
     }
     if(cloud.IsAuthenticated)
     {
         var accessToken = cloud.AccessToken;
         UriBuilder builder = new UriBuilder(cloud.YourEventUri);
         builder.Path = $"{builder.Path}/spark";
         yourEvents = new StreamEventManager(builder.Uri, accessToken);
         yourEvents.Events += YourEvents_Events;
     #if DEBUG
         yourEvents.Error += (a) =>
         {
             Debug.WriteLine($"Error: {a}");
         };
     #endif
         Task.Run(() => yourEvents.Start()); // With out the Task.Run the app freezes up not sure why
     }
 }