-4

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
  • 301
  • 3
  • 7
  • 23
  • Generally you want to ensure your idea runs _single-threaded_ before attempting to use _multiple threads_ – MickyD 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
  • 73,476
  • 14
  • 119
  • 139