0

I working with some API that need to run with async (an await in body also) but it throw an exception like this:

System.NullReferenceException: Object reference not set to an instance of an object.

when I call that api without define defaultProxy in WebConfige. But in my solution I cannot define defaultProxy because it will interrupt some other process.

I also read this post but cannot find the solution :(

So do we have anyway to run the async method without await like create background thread to run some method like ReadAsStreamAsync (just an example).

6
  • Please take a look here : stackoverflow.com/q/4660142/3956100 Commented Sep 23, 2016 at 4:32
  • Also here: stackoverflow.com/help/how-to-ask Commented Sep 23, 2016 at 4:32
  • 1
    Simple, Null reference exception is due to attempt to use a Null object to call a method, which will never work. Async-Await doesn't create background thread. You can wrap a Synchronous method like ReadAsStream in a Task like Task.Run(() => ReadAsStream()), which will still return awaitable Task, but doesn't need Async method Commented Sep 23, 2016 at 4:45
  • Yes I know it, but the main issue here is the async just run when I have default proxy. Not about the exception at all. Please read my question carefully :| Commented Sep 23, 2016 at 6:01
  • @MrinalKamboj Maybe I will go with that way Commented Sep 23, 2016 at 6:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.