Click here to Skip to main content
15,173,033 members
Home / Discussions / C#
   

C#

 
GeneralRe: Get one type of elements from dictionary Pin
Mycroft Holmes27-Jun-11 20:49
professionalMycroft Holmes27-Jun-11 20:49 
QuestionNavigating between forms Pin
Berlus26-Jun-11 2:19
MemberBerlus26-Jun-11 2:19 
AnswerRe: Navigating between forms Pin
Mycroft Holmes26-Jun-11 2:59
professionalMycroft Holmes26-Jun-11 2:59 
AnswerRe: Navigating between forms Pin
Not Active27-Jun-11 3:29
mentorNot Active27-Jun-11 3:29 
QuestionCustom control sometimes doesn't paint/refresh the button on it Pin
teknolog12326-Jun-11 0:13
Memberteknolog12326-Jun-11 0:13 
AnswerRe: Custom control sometimes doesn't paint/refresh the button on it Pin
Dave Kreskowiak27-Jun-11 10:22
mveDave Kreskowiak27-Jun-11 10:22 
QuestionStarting intrupped thread again.. Pin
shivamkalra25-Jun-11 20:06
Membershivamkalra25-Jun-11 20:06 
AnswerRe: Starting intrupped thread again.. Pin
MicroVirus26-Jun-11 1:44
MemberMicroVirus26-Jun-11 1: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 18:59
professional Xmen Real 25-Jun-11 18:59 
QuestionKnow when form loses focus? Pin
Matt U.25-Jun-11 14:30
MemberMatt U.25-Jun-11 14:30 
AnswerRe: Know when form loses focus? Pin
Dr.Walt Fair, PE25-Jun-11 17:49
professionalDr.Walt Fair, PE25-Jun-11 17:49 
GeneralRe: Know when form loses focus? Pin
Matt U.26-Jun-11 3:47
MemberMatt U.26-Jun-11 3:47 
QuestionPopulate Listview using LINQ Pin
klaydze24-Jun-11 16:22
Memberklaydze24-Jun-11 16:22 
QuestionRe: Populate Listview using LINQ Pin
Mario Majčica24-Jun-11 22:20
professionalMario Majčica24-Jun-11 22:20 
AnswerRe: Populate Listview using LINQ Pin
#realJSOP25-Jun-11 1:30
mva#realJSOP25-Jun-11 1:30 
GeneralRe: Populate Listview using LINQ Pin
Mycroft Holmes25-Jun-11 3:39
professionalMycroft Holmes25-Jun-11 3:39 
GeneralRe: Populate Listview using LINQ Pin
Dan Mos25-Jun-11 4:26
MemberDan Mos25-Jun-11 4:26 
GeneralRe: Populate Listview using LINQ Pin
Not Active27-Jun-11 3:27
mentorNot Active27-Jun-11 3:27 
AnswerRe: Populate Listview using LINQ Pin
klaydze25-Jun-11 4:25
Memberklaydze25-Jun-11 4:25 
QuestionTask queues to execute a task one by one in file downloader program. [modified] Pin
shivamkalra24-Jun-11 13:37
Membershivamkalra24-Jun-11 13:37 
AnswerRe: Task queues to execute a task one by one in file downloader program. Pin
Richard MacCutchan25-Jun-11 0:01
mveRichard MacCutchan25-Jun-11 0:01 
QuestionNot Lost focus of form. Pin
Anubhava Dimri24-Jun-11 0:46
MemberAnubhava Dimri24-Jun-11 0:46 
AnswerRe: Not Lost focus of form. Pin
Mario Majčica24-Jun-11 5:12
professionalMario Majčica24-Jun-11 5:12 
SuggestionRe: Not Lost focus of form. Pin
MicroVirus24-Jun-11 7:08
MemberMicroVirus24-Jun-11 7:08 
GeneralRe: Not Lost focus of form. Pin
Mario Majčica24-Jun-11 10:50
professionalMario Majčica24-Jun-11 10: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.