Click here to Skip to main content
15,893,190 members
Home / Discussions / C#
   

C#

 
GeneralRe: Get one type of elements from dictionary Pin
Mycroft Holmes27-Jun-11 19:49
professionalMycroft Holmes27-Jun-11 19:49 
QuestionNavigating between forms Pin
Berlus26-Jun-11 1:19
Berlus26-Jun-11 1:19 
AnswerRe: Navigating between forms Pin
Mycroft Holmes26-Jun-11 1:59
professionalMycroft Holmes26-Jun-11 1:59 
AnswerRe: Navigating between forms Pin
Not Active27-Jun-11 2:29
mentorNot Active27-Jun-11 2:29 
QuestionCustom control sometimes doesn't paint/refresh the button on it Pin
teknolog12325-Jun-11 23:13
teknolog12325-Jun-11 23:13 
AnswerRe: Custom control sometimes doesn't paint/refresh the button on it Pin
Dave Kreskowiak27-Jun-11 9:22
mveDave Kreskowiak27-Jun-11 9:22 
QuestionStarting intrupped thread again.. Pin
shivamkalra25-Jun-11 19:06
shivamkalra25-Jun-11 19:06 
AnswerRe: Starting intrupped thread again.. Pin
MicroVirus26-Jun-11 0:44
MicroVirus26-Jun-11 0:44 
Is it really necessary to resort to threads here?
And if the answer is yes, then more specifically, is it really necessary to resort to multiple GUI-altering threads?

Why not just make the main (GUI) thread have a method that updates the text box and a Timer control that triggers after 10 seconds to reset the contents of the text box.
When a new text-event occurs, your method is called again, and you reset the timer to 10 seconds again.

Something in the way of (incomplete code):
void AddNotification(string NotifyText)
{
  // Note: depending on if you're sticking to multiple threads, 
  // you might actually need to use Invokes here. Possibly you could
  // force the caller to do the Invoke and throwing an exception if
  // the caller didn't
  Timer1.Enabled = false;
  MessageLbl.Text = NotifyText;
  Timer1.Enabled = true;
}

// Timer event function (can't remember at the top my head how C# names it exactly)
void Timer1_Timer(object sender)
{
  Timer1.Enabled = false;
  MessageLbl.Text = "Default text here";
}


With Timer1's timeout set to 10 seconds. If your GUI thread is doing some intensive work, then the timer might not fire until after the work is done. If that is a problem, thát would be the time to use threads, to do the work in a background thread while the GUI remains responsive.
All in all, it's best to have the main thread handle all GUI.
QuestionNamedPipeClientStream.Connect(int) doesn't throw Exception if Form is closed. [fixed, workaround] Pin
Xmen Real 25-Jun-11 17:59
professional Xmen Real 25-Jun-11 17:59 
QuestionKnow when form loses focus? Pin
Matt U.25-Jun-11 13:30
Matt U.25-Jun-11 13:30 
AnswerRe: Know when form loses focus? Pin
Dr.Walt Fair, PE25-Jun-11 16:49
professionalDr.Walt Fair, PE25-Jun-11 16:49 
GeneralRe: Know when form loses focus? Pin
Matt U.26-Jun-11 2:47
Matt U.26-Jun-11 2:47 
QuestionPopulate Listview using LINQ Pin
klaydze24-Jun-11 15:22
klaydze24-Jun-11 15:22 
QuestionRe: Populate Listview using LINQ Pin
Mario Majčica24-Jun-11 21:20
professionalMario Majčica24-Jun-11 21:20 
AnswerRe: Populate Listview using LINQ Pin
#realJSOP25-Jun-11 0:30
mve#realJSOP25-Jun-11 0:30 
GeneralRe: Populate Listview using LINQ Pin
Mycroft Holmes25-Jun-11 2:39
professionalMycroft Holmes25-Jun-11 2:39 
GeneralRe: Populate Listview using LINQ Pin
Dan Mos25-Jun-11 3:26
Dan Mos25-Jun-11 3:26 
GeneralRe: Populate Listview using LINQ Pin
Not Active27-Jun-11 2:27
mentorNot Active27-Jun-11 2:27 
AnswerRe: Populate Listview using LINQ Pin
klaydze25-Jun-11 3:25
klaydze25-Jun-11 3:25 
QuestionTask queues to execute a task one by one in file downloader program. [modified] Pin
shivamkalra24-Jun-11 12:37
shivamkalra24-Jun-11 12:37 
AnswerRe: Task queues to execute a task one by one in file downloader program. Pin
Richard MacCutchan24-Jun-11 23:01
mveRichard MacCutchan24-Jun-11 23:01 
QuestionNot Lost focus of form. Pin
Anubhava Dimri23-Jun-11 23:46
Anubhava Dimri23-Jun-11 23:46 
AnswerRe: Not Lost focus of form. Pin
Mario Majčica24-Jun-11 4:12
professionalMario Majčica24-Jun-11 4:12 
SuggestionRe: Not Lost focus of form. Pin
MicroVirus24-Jun-11 6:08
MicroVirus24-Jun-11 6:08 
GeneralRe: Not Lost focus of form. Pin
Mario Majčica24-Jun-11 9:50
professionalMario Majčica24-Jun-11 9:50 

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.