c# - Why put standard dialogs on a form? -


itemprop = "text">

I have some legacy code C #, .Net 2.0 where someone pulled OpenBuffDialog and SaveFileDialaog from the toolbox to the form. The result of this is to open and save the dialogue promptly, when their parent communication is created and remaining until the original dialogue is closed. The open / saved forms are actually used only for a support file in one place which is not always opened / saved during the life of the original dialogue; It looks disabled for me what I will do:

  (OpenFileDialog openDlg = new OpenFileDialog ()) Use {// initial.dll} ... if (openDlg.ShowDialog ()! = DialogResult.OK) {// handle the results properly}}  

OpenFileDialog will be disposed of in this way when the statement used will be out of the scope. Unless I am missing nothing, the value of the quick disposal of the resource (and the fast waste collection) is required, then the open / save file does not extend the small amount of money to the dialogue, even if it is open / Save dialogs are used every time their parents interact, I have not seen any great value for them being around all the time. My question is, am I forgetting something? Is there any more efficiency to keep open / save dialogs all the time? I think the answer would be similar to all other standard dialogues: ColorDialog, FolderBrowserDialog and FontDialog.

Not required. There is a displacement () method in these dialogues, because they obtain one from a component class. They do not override this method because there really is nothing to deal with. All the system resources that are used are released when the dialog stops. Component. Dispose () implementation does not do any settlement, it just ensures that the component has been removed from the IContainer collection.

This is otherwise an implementation description of these dialog rappers. Other components are commonly used for disposal (), tooltip is a good example of the auto-generated disposable method for a form that ensures that this happens, the form of the Designer.cs source code in the file "component "See the field. This is why the component has a disposable system that does nothing important by default.

There is a teen advantage to avoid leaving the component on the form, it allows the .NET wrapper class to communicate. Garbage can be collected or saved from a kilobyte or a micro-optimization.

Put it at face value: If it was important to quickly settle these class objects, then Microsoft would not have made them poor.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -