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).
Null reference exceptionis due to attempt to use aNullobject to call a method, which will never work.Async-Awaitdoesn't create background thread. You can wrap a Synchronous method likeReadAsStreamin aTasklikeTask.Run(() => ReadAsStream()), which will still returnawaitable Task, but doesn't needAsyncmethod