DO NOT Save Password in Web.Config or App.Config Directly

We saved passwords in project config file normally when we developed the project, However, it should be different when you deploy your project since most of time you should avoid your customer to touch some system passwords such as the database connection password, some of your API’s passwords such as Google+ API secret codes;

Continue reading “DO NOT Save Password in Web.Config or App.Config Directly”

Experienced Software Developer Still Faces to Code or Basic Acknowledge Test When Interview

As a IT guy, a Software Developer, a Microsoft technologies developer (from C++ to .NET ) with over 24 years development history, I still have to face to some awkward (embarrassed ? ) situations such as job interviews. I left school so many years, but some interviews still needed me to give correct answers for some basic computer and programming acknowledges, such as: What is C# ? What features does OO have ? or I was asked for writing code to give a good performance program to implement a scanning or searching case based on stack or queue ….

Continue reading “Experienced Software Developer Still Faces to Code or Basic Acknowledge Test When Interview”

How to disable Progress bar’s animation in .NET

The Windows Forms progress bar control comes with re-draw bar function by default, you will see the drawing process from left to right when you have one or multiple progress bar controls on your screen.

So how to disable the animation since in some cases we do not want to see the re-drawing.

There is no a good solution for it. But there is a simple way to resolve the issue, but just looked wired.

Just put the following code, and then you set the value to progress bar, the animation will gone ! Because the progress bar has a wired feature: when you set a value to it, and –1 right away, the animation will be disappear!

this.progressBar1.Maximum = 101;  
this.progressBar1.Value = 101;
this.progressBar1.Maximum = 100;

A Simulator Program Using WPF

This simulator program was for simulating a special company devices, which are for Coal Mine field gas detection.

We had plan to continue release new version, however, the time was occupied by most other software projects after this simulator program 1st version released. At that time the simulator worked perfect for company new computer control system internal testing. Actually, why this Simulator program built just because of internal testing requirement.

Continue reading “A Simulator Program Using WPF”

Windows Form FlowLayoutPanel Memory Leak ?

There were not only one time, and there were lots of programmer who used Windows Form FlowLayoutPanel control got the memory leak issues.

In our case, we used FlowLayoutPanel control wrapped multiple user controls which include PictureBox controls and other controls. we need constantly clear the FlowLayoutPanel and add new user controls. We found the memory leak, looks like the FlowLayoutPanel did not “clear”, finally we found when we load FlowLayoutPanel clear method, the user controls seems still in the memory (with PictureBox maybe).

So we tried the manually load Dispose method before clear. like the following:

foreach (Control ctrl in flowlayoutpanal1.Controls) { ctrl.Dispose(); 

} flowlayoutpanal1.Controls.Clear();

Also, we added other code in User Control’s dispose method to dispose any 3rd party controllers which are not Microsoft Windows Form controllers.

However, we found the memory leak issue still there, we did not fix it.

Actually, in above code, we made a classic .NET error: when control disposed, it also was removed from its parent control. so the children controls of flowlayoutpanel1 always changed. so we should not use “foreach” for a changed list.

So now you know how you should dispose the children controls, the following is a sample, use For loop, and NOT from beginning, but from end of the list:

for(int i = flowlayoutpanel1.Controls.Count-1; i >= 0; --i)
{ 
   var ctl = flowlayoutpanel1.Controls[i];
    ctl.Dispose();
}