-3

I have declared a UITableView tableView with a getter/setter

I want to use this tableView asynchronously

await Task.Run (() => getResult ()

inside the getResult method, I try to access the tableView on the main thread

InvokeOnMainThread (() => {
            tableView.Hidden = false;
        });

This results in a

Null Reference Exception

How can I access the tableView asynchronously without getting a null reference exception. Is there any workaround to this?

jipot
  • 304
  • 3
  • 13
  • 34
  • Generally you want to ensure your idea runs _single-threaded_ before attempting to use _multiple threads_ –  Dec 06 '15 at 04:33

1 Answers1

1

You need to initialize tableView before you can reference it. A getter/setter will not automatically initialize it for you. For example, in your constructor you could

tableView = new UITableView();
Jason
  • 86,222
  • 15
  • 131
  • 146