Click here to Skip to main content
15,919,931 members
Home / Discussions / C#
   

C#

 
GeneralRe: thread Pin
Not Active13-Feb-08 3:12
mentorNot Active13-Feb-08 3:12 
GeneralRe: thread Pin
Bekjong13-Feb-08 3:19
Bekjong13-Feb-08 3:19 
GeneralRe: thread Pin
Spacix One13-Feb-08 5:08
Spacix One13-Feb-08 5:08 
GeneralAbnormal thread results Pin
Yoyosch13-Feb-08 2:21
Yoyosch13-Feb-08 2:21 
GeneralRe: Abnormal thread results Pin
Bekjong13-Feb-08 3:01
Bekjong13-Feb-08 3:01 
GeneralRe: Abnormal thread results Pin
CKnig13-Feb-08 3:02
CKnig13-Feb-08 3:02 
GeneralRe: Abnormal thread results [modified] Pin
Yoyosch13-Feb-08 3:16
Yoyosch13-Feb-08 3:16 
GeneralThreadding Issue Pin
Harvey Saayman13-Feb-08 1:40
Harvey Saayman13-Feb-08 1:40 
Hey guyz

Im having a problem with a userControll im writing. Basicly its a label that changes color based on the "status" of it red, yello or green. and then i use that to disply errors and general info like "Enter User Details Here"

Now on some of the forms of my app the posible error messages is longer than the form itself for example "Database Connection No Longer Avalibal > Transaction Terminated". So when i got at work this morning i decided to make the labels text scroll past.

this is the code i have so far (its not my actual controll, its just a test project)
its a form with a label on it

public partial class Form1 : Form
    {
        char charTemp;
        string tempMessage = "";
        string message = "";
        TimerCallback timeCB;
        System.Threading.Timer timer;        

        public Form1()
        {
            InitializeComponent();
        }

        public void scrollText(object state)
        {
            message = label1.Text;

            charTemp = message[0];

            for (int i = 0; i < message.Length - 1; i++)
            {
                tempMessage += message[i + 1];
            }
            tempMessage += charTemp;
            label1.Text = tempMessage;
            tempMessage = "";
        }

        private void Form1_Shown(object sender, EventArgs e)
        {
            timeCB = new TimerCallback(scrollText);
            timer = new System.Threading.Timer(timeCB, null, 0, 1000);
        }
    }


now the obvios error i get is "Cross-thread operation not valid". But there must be a way to update the labels text after the 2nd thread runs its method

any ideas on how i can get it working?

Thanx

Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS

GeneralRe: Threadding Issue Pin
Giorgi Dalakishvili13-Feb-08 1:47
mentorGiorgi Dalakishvili13-Feb-08 1:47 
GeneralRe: Threadding Issue Pin
Harvey Saayman13-Feb-08 2:10
Harvey Saayman13-Feb-08 2:10 
GeneralRe: Threadding Issue Pin
Giorgi Dalakishvili13-Feb-08 2:20
mentorGiorgi Dalakishvili13-Feb-08 2:20 
GeneralRe: Threadding Issue Pin
Bekjong13-Feb-08 2:56
Bekjong13-Feb-08 2:56 
GeneralRe: Threadding Issue Pin
Harvey Saayman13-Feb-08 3:16
Harvey Saayman13-Feb-08 3:16 
GeneralRe: Threadding Issue Pin
Bekjong13-Feb-08 3:27
Bekjong13-Feb-08 3:27 
GeneralRe: Threadding Issue Pin
Harvey Saayman13-Feb-08 3:31
Harvey Saayman13-Feb-08 3:31 
GeneralRe: Threadding Issue Pin
Bekjong13-Feb-08 3:46
Bekjong13-Feb-08 3:46 
GeneralRe: Threadding Issue Pin
GuyThiebaut13-Feb-08 4:09
professionalGuyThiebaut13-Feb-08 4:09 
GeneralSoap Serialization vs Binary vs XML Pin
asdf98913-Feb-08 1:00
asdf98913-Feb-08 1:00 
GeneralRe: Soap Serialization vs Binary vs XML Pin
CKnig13-Feb-08 2:24
CKnig13-Feb-08 2:24 
Generalquick tcp question Pin
pokabot13-Feb-08 0:50
pokabot13-Feb-08 0:50 
GeneralRe: quick tcp question Pin
stancrm13-Feb-08 1:57
stancrm13-Feb-08 1:57 
GeneralRe: quick tcp question Pin
pokabot13-Feb-08 9:20
pokabot13-Feb-08 9:20 
GeneralRe: quick tcp question [modified] Pin
engsrini13-Feb-08 15:51
engsrini13-Feb-08 15:51 
General[Message Deleted] Pin
chithra.r13-Feb-08 0:27
chithra.r13-Feb-08 0:27 
GeneralWrong forum? Pin
Mircea Puiu13-Feb-08 0:39
Mircea Puiu13-Feb-08 0:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.