我该如何管理static带有一次性物品的课程?有没有经验法则?
基本上,我应该重构并做下面的DisposableDataManager课程,non-
static还是把一切都留下来GC好吗?
.
public static class DisposableDataManager
{
// ImageList is an 'IDisposable'.
public static ImageList FirstImageList { get; private set; }
public static ImageList SecondImageList { get; private set; }
static DisposableDataManager()
{
FirstImageList = CreateFirstImageList();
SecondImageList = CreateSecondImageList();
}
// ...
}
Run Code Online (Sandbox Code Playgroud)