Tuesday, November 30, 2010

Force .NET controls to refresh their content

Often when doing a given task in a loop c# program did not bother updating the content of controls until the loop ends. So for example when the program has to update the text of a button at the end of each iteration to give the user a feedback about the advance in the process, it will not be done. This of course has been done for good reason, namely forcing the control the refresh will degrades the performance of the process but in certain case the display of the updated text could anyway be desirable. So to force the refresh write the following line in your code:

label1.Text = "Processing 1 of 10 ...";
Application.DoEvents(); 

 The DoEvent() function allow the form to execute all task in the task list, without wait for the last task to finish.

Thursday, November 18, 2010

MS visual studio - debug / release options

I am really a big fan of visual studio, but today I helped a friend installing visual studio express edition on his computer and we find out that the release/debug option beside the play button was disabled...strange. So we google the question. Thus we find out that turning back on the release/debug option was quite cumbersome.
The response was find on stackoverflow (http://stackoverflow.com/questions/2812423/how-to-switch-between-debug-release-in-visual-c-2010-express)

And reported here for your convenience:
"
  1. Enable Tools -> Settings -> Expert Settings.
  2. Go to Tools -> Options. In the dialog box, check the Show All Settings option in the bottom left.
  3. In the above dialog, now choose Projects and Solutions -> General. Check the option Show advanced build configurations. Click Okay.

"

Tuesday, November 16, 2010

Friday, November 12, 2010

CodeVisionAVR's contra-intuitive pin commmand

For Atmel micro controller programming people often use CodeVisionAVR (http://www.hpinfotech.ro/html/cvavr.htm) which is a good IDE for the development. I recently started to use it myself and I end up spending several hour trying to catch a bug in my code that do not exists. The problem was the following:

CodeVision c language libraries offers you the useful command PINx.y command, per example PINC.1 mean pin 1 of IO port C. But one should know that PINx.y command is meant to be used as read or toggle function only.

read function:
int a = PINC.1 //will assigned the logical value of pin 1 on port C to the variable a

toggle function
//assuming pin 1 of port C is low
PINC.1=1; //  toggle to high
PINC.1=1; //  toggle back to low

To actually write to the output the logical value you really want you should use the PORTx.y command:

PORTC.1=1;   //pin 1 of port C is set to 1
PORTC.1=1;  //pin 1 of port C is set to 1
PORTC.1=0;  //pin 1 of port C is set to0

Tuesday, November 9, 2010

synchronization of outlook and gmail calendar

Since recently I am the proud owner of a brand new Galaxy S running under Android 2.1. One of the issue I encounter is how to synchronize my oulook calendar with my Gmail one. Fortunatly Google make a very usefull tool available making all the work for you:

http://www.google.com/support/calendar/bin/answer.py?answer=89955