Does the Garbage Collector destroy temporarily unreferenced objects during async calls in .NET?

后端 未结 5 1731
刺人心
刺人心 2020-12-11 03:20

Imagine that I will make an async call in .NET, i.e. HttpWebRequest.BeginGetResponse, and the HttpWebRequest object isn\'t referenced at a broader scope. Will the Garbage Co

5条回答
  •  眼角桃花
    2020-12-11 03:58

    If an object has no references as far as the GC is concerned then you can no longer get a reference to it. So you can't have an object that temporarily doesn't have a reference to it.

    (This assumes nothing sneaky like unmanaged or unsafe code playing games)

提交回复
热议问题