ערכתי לאחרונה בתאריך 28.12.08 בשעה 11:59 בברכה, ronen333
עשיתי WINDOW APPLICTION והעברתי אובייקט TEXTBOX למחלקה אחרת ובמחלה הזאת אני משנה את הערך טקסט. (DIGITAL זה הפקד TEXTBOX)
אבל זה זורק לי-
Cross-thread operation not valid: Control 'digital' accessed from a thread other than the thread it was created on.
partial class Form1 : Form { public Form1() { InitializeComponent(); clock = new Clock(digital); } private void start_Click(object sender, System.EventArgs e) { this.clock.Start(); } private void stop_Click(object sender, System.EventArgs e) { this.clock.Stop(); } private Clock clock; }
|
class Clock { public Clock(TextBox displayBox) { this.display = displayBox; } public void Start() { //pulsed.Add(this.RefreshTime); pulsed.tick += this.RefreshTime; } public void Stop() { //pulsed.Remove(this.RefreshTime); pulsed.tick -= this.RefreshTime; } private void RefreshTime(int hh, int mm, int ss) { this.display.Text = string.Format("{0:D2}:{1:D2}:{2:D2}", hh, mm, ss); } private Ticker pulsed = new Ticker(); private TextBox display; }
|
למה זה זורק לי EXCEPTION כזה? (מה לא חוקי בזה? X= )
תודה לעוזרים

