0

I'm currently trying to make an application were you can chat with people via the Firebase database and I have managed to retrieve data and set data into the database. But when I retrieve data from the stream, I can only view it with a Messagebox. Show or any type of System stuff.

I want to add the result to a listbox but its not letting me.

Here is the code (I have also tried to remove static)

private static async void EventStreaming()
    {
        var response = await _client.OnAsync("chat",
            (sender, args, context) => { listBox1.Items.Add("" + args.Data); },
            (sender, args, context) => { listBox1.Items.Add("" + args.Data); },
            (sender, args, context) => { listBox1.Items.Add("" + args.Path); });

        //Call dispose to stop listening for events
        //response.Dispose();
    }
KENdi
  • 7,576
  • 2
  • 16
  • 31
Nais
  • 1
  • 1
  • _its not letting me_ is not a clear description of your problem. What specific error do you receive. Taking a guess, it looks as though your trying to access a ui element from another thread which would cause an error. See [this](https://stackoverflow.com/questions/21114831/access-ui-element-from-non-ui-thread) among many other discussions of the topic. – JSteward Oct 03 '17 at 22:33
  • Basicly when i try to add it to listbox i get an error but if its any type of system object it want to return the result on it will work, like System.Console or Messagebox.show. Any type of form object like label, textbox and a listbox will not work. Error: CS0120: An object reference is required for the nonstatic field, method, or property – Nais Oct 06 '17 at 14:45
  • @Nais did you ever figure this out? – Cflux Feb 06 '21 at 23:22

0 Answers0