Оцените презентацию от 1 до 5 баллов!
Тип файла:
ppt / pptx (powerpoint)
Всего слайдов:
20 слайдов
Для класса:
1,2,3,4,5,6,7,8,9,10,11
Размер файла:
421.55 kB
Просмотров:
58
Скачиваний:
0
Автор:
неизвестен
Слайды и текст к этой презентации:
№1 слайд![The Basics of Object](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img0.jpg)
Содержание слайда: The Basics of Object Lifetime.
Disposing objects.
№2 слайд![AGENDA The Basics of Object](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img1.jpg)
Содержание слайда: AGENDA
The Basics of Object Lifetime
Building Finalizable Objects
Building Disposable Objects
Dispose pattern
№3 слайд![The Basics of Object Lifetime](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img2.jpg)
Содержание слайда: The Basics of Object Lifetime
№4 слайд![The Basics of Object Lifetime](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img3.jpg)
Содержание слайда: The Basics of Object Lifetime
№5 слайд![The Role of Application Roots](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img4.jpg)
Содержание слайда: The Role of Application Roots
Root is a storage location containing a reference to an object on the managed heap:
• References to global objects
• References to any static objects/static fields
• References to local objects within an application’s code base
• References to object parameters passed into a method
• References to objects waiting to be finalized
• Any CPU register that references an object
№6 слайд![Object Generations Each](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img5.jpg)
Содержание слайда: Object Generations
Each object on the heap belongs to one of the following generations:
• Generation 0: Identifies a newly allocated object that has never been marked for collection.
• Generation 1: Identifies an object that has survived a garbage collection (i.e., it was marked for collection but was not removed due to the fact that the sufficient heap space was acquired).
• Generation 2: Identifies an object that has survived more than one sweep of the garbage collector.
№7 слайд![Building Finalizable Objects](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img6.jpg)
Содержание слайда: Building Finalizable Objects
Rule The reason to override Finalize() is if your C# class is making use of unmanaged resources via PInvoke or complex COM interoperability tasks. The reason is that you are manipulating memory that the CLR cannot manage.
№8 слайд![Building Finalizable Objects](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img7.jpg)
Содержание слайда: Building Finalizable Objects
You can’t override the Finalize() method directly in your class, but you may use of a destructor syntax to achieve the same effect.
Destructor never takes an access modifier (implicitly protected), never takes parameters, and can’t be overloaded (only one finalizer per class).
№9 слайд![Building Disposable Objects](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img8.jpg)
Содержание слайда: Building Disposable Objects
№10 слайд![](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img9.jpg)
№11 слайд![](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img10.jpg)
№12 слайд![using](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img11.jpg)
№13 слайд![?](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img12.jpg)
№14 слайд![Dispose pattern The Dispose](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img13.jpg)
Содержание слайда: Dispose pattern
The Dispose Pattern is intended to standardize the usage and implementation of finalizers and the IDisposable interface.
√ DO implement the Basic Dispose Pattern on types containing instances of disposable types.
√ DO implement the Basic Dispose Pattern and provide a finalizer on types holding resources that need to be freed explicitly and that do not have finalizers.
√ CONSIDER implementing the Basic Dispose Pattern on classes that themselves don’t hold unmanaged resources or disposable objects but are likely to have subtypes that do.
№15 слайд![Dispose pattern Involves](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img14.jpg)
Содержание слайда: Dispose pattern
Involves implementing the System.IDisposable interface
Declare the Dispose(bool) method that implements all resource cleanup logic to be shared between the Dispose method and the optional finalizer.
№16 слайд![Dispose pattern DO NOT make](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img15.jpg)
Содержание слайда: Dispose pattern
DO NOT make the parameterless Dispose method virtual.
The Dispose(bool) method is the one that should be overridden by subclasses.
№17 слайд![Dispose pattern DO allow the](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img16.jpg)
Содержание слайда: Dispose pattern
√ DO allow the Dispose(bool) method to be called more than once. The method might choose to do nothing after the first call.
№18 слайд![Dispose pattern DO throw an](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img17.jpg)
Содержание слайда: Dispose pattern
√ DO throw an ObjectDisposedException from any member that cannot be used after the object has been disposed of.
№19 слайд![Dispose pattern CONSIDER](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img18.jpg)
Содержание слайда: Dispose pattern
√ CONSIDER providing method Close(), in addition to the Dispose(), if close is standard terminology in the area.
№20 слайд![Questions ?](/documents_6/f6cf64d31f1e54dbd8ef983888a512e6/img19.jpg)
Содержание слайда: Questions ?