FEZ Domino, Red Six Button LCD Shield, Clock disaster

I am trying to build a clock, I will be using the buttons as ways to get to my functions I want henceforth they are not programmed in yet. But I want the Date to flash for five seconds, and then the Time to Flash for five seconds on the first row of the Keypad Shield. Since I do not want the buttons to go unanswered for 5 to 10 seconds, I have tried to make the time/date it’s own thread. This program works fine for about a minute and a half, then the screen starts going haywire and chinese characters start displaying. This is not a determinate time either as it can fail immediately, or it can last as long as three minutes. In addition, I do not get any blobs from the Domino, which I thought might help me fix the problem. Since I can not get a blob to show up this and my code is about as much as I can offer. I have added the relevant program below. I am sure this is something stupid on my part, but as I or my friend can not find the problem I am asking for help here.

using System;
using System.Threading;

using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

using GHIElectronics.NETMF.FEZ;

namespace DisplayProject
{
    public class Program
    {

        public static void Main()
        {
            SetTime();

            FEZ_Shields.KeypadLCD.Initialize();
            FEZ_Shields.KeypadLCD.TurnBacklightOn();


            Thread startTimeDisplay = new Thread(TimeDateBlink);        //<<<<<========  Starting a seperate thread for the date and time to blink.
            startTimeDisplay.Start();

            while (true)
            {
                
                FEZ_Shields.KeypadLCD.SetCursor(1, 0);
                switch (FEZ_Shields.KeypadLCD.GetKey())
                {
                    case FEZ_Shields.KeypadLCD.Keys.Up:
                        FEZ_Shields.KeypadLCD.Print("Up              ");
                        break;
                    case FEZ_Shields.KeypadLCD.Keys.Down:
                        FEZ_Shields.KeypadLCD.Print("Down            ");
                        break;
                    case FEZ_Shields.KeypadLCD.Keys.Left:
                        FEZ_Shields.KeypadLCD.Print("Left            ");
                        break;
                    case FEZ_Shields.KeypadLCD.Keys.Right:
                        FEZ_Shields.KeypadLCD.Print("Right           ");
                        break;
                    case FEZ_Shields.KeypadLCD.Keys.Select:
                        FEZ_Shields.KeypadLCD.Print("Select          ");
                        break;
                    case FEZ_Shields.KeypadLCD.Keys.None:
                        FEZ_Shields.KeypadLCD.Print("                ");
                        break;
                }
                Thread.Sleep(100);
            }
        }

        static void TimeDateBlink()                                                              //  <<<<<=====================   This is the time date blinker, it blinks the date and the time, Date for a flat five seconds, 
        {                                                                                                           //  Seconds are blinked every second, but it looks like time blinks for five seconds.  Gives the illusion of a running clock.
            int counter = 0;                                                                               
            string currentTime = "";
            string currentDate = "";

            while (true)                                                                                   //  This thread is meant to run as long as the display is running.  Thus no end.
            {
                FEZ_Shields.KeypadLCD.CursorHome();
                currentTime = GetTime();
                currentDate = GetDate();
                FEZ_Shields.KeypadLCD.Print(currentDate);  //  << ==  Supposed to print the time.
                Thread.Sleep(5000);
                counter = 0;
                while (counter < 5)   //  <<< ===  To give the illusion of the clock ticking the seconds, I have to update the time each second.
                {
                    currentTime = GetTime();
                    FEZ_Shields.KeypadLCD.CursorHome();         //  <<<  Brings the display position back to the top row, first character
                    FEZ_Shields.KeypadLCD.Print("                 ");   //  <<<  Clears the display.
                    FEZ_Shields.KeypadLCD.CursorHome(); 
                    FEZ_Shields.KeypadLCD.Print(currentTime);   //  Prints the time.
                    Thread.Sleep(1000);                                             //  Wait a second before updating.
                    counter++;
                } ;
            }
        }

        private static void SetTime()
        {
            // set the time to 05/19/2011 at 19:30:00
            DateTime DeviceTime = new DateTime(2011, 5, 20, 23, 30, 0);
            Utility.SetLocalTime(DeviceTime);
        }

        private static string GetTime()
        {
            string currentTime = "";
            currentTime = DateTime.Now.TimeOfDay.ToString();
            currentTime = currentTime.Substring(0, 8);
            return currentTime;
        }

        private static string GetDate()
        {
            string currentDate = "";
            currentDate = DateTime.Today.ToString();
            currentDate = currentDate.Substring(0, 10);
            return currentDate;
        }
    }
}

Only one thread should “own” the serial port. You are probably doing something wierd like both threads accessing the serial port at the same time and putting the LCD controller into a strange mode (like selecting a different char set).

What you can do is create a function like this:


[MethodImpl(MethodImplOptions.Synchronized)]
static void SetLCDText(string text)
{
     FEZ_Shields.KeypadLCD.Print(text);
}

Then call the function where you need to set the text. This will guarentee that at any one time only one thread is accessing the LCD.