Click here to Skip to main content
15,166,053 members
Home / Discussions / C#
   

C#

 
AnswerRe: Derived Treeview override not being called at all. Pin
Richard Deeming4-Nov-21 5:01
mveRichard Deeming4-Nov-21 5:01 
GeneralRe: Derived Treeview override not being called at all. Pin
primem0ver4-Nov-21 6:17
Memberprimem0ver4-Nov-21 6:17 
GeneralRe: Derived Treeview override not being called at all. Pin
Richard Deeming4-Nov-21 6:32
mveRichard Deeming4-Nov-21 6:32 
GeneralRe: Derived Treeview override not being called at all. Pin
primem0ver4-Nov-21 6:42
Memberprimem0ver4-Nov-21 6:42 
GeneralRe: Derived Treeview override not being called at all. Pin
BillWoodruff5-Nov-21 0:56
mveBillWoodruff5-Nov-21 0:56 
AnswerRe: Derived Treeview override not being called at all. Pin
BillWoodruff5-Nov-21 0:55
mveBillWoodruff5-Nov-21 0:55 
SuggestionCron mechanism Pin
johnpierwszy3-Nov-21 23:34
Memberjohnpierwszy3-Nov-21 23:34 
GeneralRe: Cron mechanism Pin
OriginalGriff3-Nov-21 23:54
mveOriginalGriff3-Nov-21 23:54 
You either need to set up a Timer Class (System.Timers) | Microsoft Docs[^] or a BackgroundWorker Class (System.ComponentModel) | Microsoft Docs[^]

Either will do, but without one or the other, you will block the UI thread waiting for the timeout to elapse - which will make it look like the whole application is locked up!

Me? I'd use a background worker and use the Progress reporting mechanism to update the UI thread when necessary:
C#
private void FrmMain_Shown(object sender, EventArgs epp)
    {
    BackgroundWorker work = new BackgroundWorker();
    work.DoWork += Work_DoWork;
    work.ProgressChanged += Work_ProgressChanged;
    work.RunWorkerCompleted += Work_RunWorkerCompleted;
    work.WorkerReportsProgress = true;
    work.RunWorkerAsync("A parameter of any type you want to pass it");
    }

private void Work_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
    MyTextBox.Text = "Done.";
    }

private void Work_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
    MyTextBox.Text = ($"Progress: {e.ProgressPercentage} - {e.UserState as string}");
    }

private void Work_DoWork(object sender, DoWorkEventArgs e)
    {
    if (sender is BackgroundWorker work)
        {
        for (int i = 0; i < 1000000; i++)
            {
            Thread.Sleep(1000);
            work.ReportProgress(i / 10000, $"An object of any type you want to pass back to the main thread: {i}");
            }
        }
    }

"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!

GeneralRe: Cron mechanism Pin
johnpierwszy4-Nov-21 0:13
Memberjohnpierwszy4-Nov-21 0:13 
GeneralRe: Cron mechanism Pin
OriginalGriff4-Nov-21 0:18
mveOriginalGriff4-Nov-21 0:18 
GeneralRe: Cron mechanism Pin
johnpierwszy4-Nov-21 0:21
Memberjohnpierwszy4-Nov-21 0:21 
GeneralRe: Cron mechanism Pin
OriginalGriff4-Nov-21 0:34
mveOriginalGriff4-Nov-21 0:34 
GeneralRe: Cron mechanism Pin
johnpierwszy4-Nov-21 1:02
Memberjohnpierwszy4-Nov-21 1:02 
GeneralRe: Cron mechanism Pin
OriginalGriff4-Nov-21 1:54
mveOriginalGriff4-Nov-21 1:54 
GeneralRe: Cron mechanism Pin
johnpierwszy4-Nov-21 2:09
Memberjohnpierwszy4-Nov-21 2:09 
GeneralRe: Cron mechanism Pin
OriginalGriff4-Nov-21 2:59
mveOriginalGriff4-Nov-21 2:59 
GeneralRe: Cron mechanism Pin
johnpierwszy4-Nov-21 7:16
Memberjohnpierwszy4-Nov-21 7:16 
Questionmissing a meow ? observations of Net#5 C#9 'record' structures in a VS 2019 WinForm project Pin
BillWoodruff3-Nov-21 12:21
mveBillWoodruff3-Nov-21 12:21 
QuestionC# regarding running multiple task Pin
Mou_kol1-Nov-21 9:15
MemberMou_kol1-Nov-21 9:15 
AnswerRe: C# regarding running multiple task Pin
OriginalGriff1-Nov-21 23:49
mveOriginalGriff1-Nov-21 23:49 
AnswerRe: C# regarding running multiple task Pin
lmoelleb1-Nov-21 23:53
Memberlmoelleb1-Nov-21 23:53 
AnswerRe: C# regarding running multiple task Pin
Gerry Schmitz2-Nov-21 8:53
mveGerry Schmitz2-Nov-21 8:53 
QuestionC# reading multiple files by multiple thread issue Pin
Mou_kol1-Nov-21 9:13
MemberMou_kol1-Nov-21 9:13 
QuestionRe: C# reading multiple files by multiple thread issue Pin
Member 153296131-Nov-21 9:29
MemberMember 153296131-Nov-21 9:29 
AnswerRe: C# reading multiple files by multiple thread issue Pin
Randor 1-Nov-21 16:41
professional Randor 1-Nov-21 16:41 

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.