How do I unit test a finalizer?

前端 未结 4 1508
不思量自难忘°
不思量自难忘° 2021-02-05 07:25

I have the following class which is a decorator for an IDisposable object (I have omitted the stuff it adds) which itself implements IDisposable using

4条回答
  •  -上瘾入骨i
    2021-02-05 08:01

    I might be misunderstanding, but:

    GC.WaitForPendingFinalizers();
    

    Might do the trick - http://msdn.microsoft.com/en-us/library/system.gc.waitforpendingfinalizers.aspx

提交回复
热议问题