Click here to Skip to main content
15,122,083 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# reading multiple files by multiple thread issue Pin
Gerry Schmitz2-Nov-21 8:53
mveGerry Schmitz2-Nov-21 8:53 
AnswerRe: C# reading multiple files by multiple thread issue Pin
primem0ver4-Nov-21 6:47
Memberprimem0ver4-Nov-21 6:47 
QuestionThread Label Updating Pin
Member 1540852926-Oct-21 9:15
MemberMember 1540852926-Oct-21 9:15 
AnswerRe: Thread Label Updating Pin
Gerry Schmitz26-Oct-21 9:36
mveGerry Schmitz26-Oct-21 9:36 
GeneralRe: Thread Label Updating Pin
Member 1540852926-Oct-21 10:17
MemberMember 1540852926-Oct-21 10:17 
AnswerRe: Thread Label Updating Pin
OriginalGriff26-Oct-21 9:59
mveOriginalGriff26-Oct-21 9:59 
GeneralRe: Thread Label Updating Pin
Member 1540852926-Oct-21 10:15
MemberMember 1540852926-Oct-21 10:15 
GeneralRe: Thread Label Updating Pin
OriginalGriff26-Oct-21 23:17
mveOriginalGriff26-Oct-21 23:17 
That's fairly easy:
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: Thread Label Updating Pin
Gerry Schmitz28-Oct-21 7:43
mveGerry Schmitz28-Oct-21 7:43 
GeneralRe: Thread Label Updating Pin
OriginalGriff28-Oct-21 21:17
mveOriginalGriff28-Oct-21 21:17 
AnswerRe: Thread Label Updating Pin
BillWoodruff26-Oct-21 17:55
mveBillWoodruff26-Oct-21 17:55 
Question.NET with problems Pin
Ismael Oliveira 202123-Oct-21 10:48
MemberIsmael Oliveira 202123-Oct-21 10:48 
AnswerRe: .NET with problems Pin
Dave Kreskowiak23-Oct-21 13:15
mveDave Kreskowiak23-Oct-21 13:15 
AnswerRe: .NET with problems Pin
Gerry Schmitz23-Oct-21 17:00
mveGerry Schmitz23-Oct-21 17:00 
AnswerRe: .NET with problems Pin
BillWoodruff23-Oct-21 22:04
mveBillWoodruff23-Oct-21 22:04 
AnswerRe: .NET with problems Pin
Matthew Dennis26-Oct-21 9:52
sysadminMatthew Dennis26-Oct-21 9:52 
QuestionC# Virtual Camera Pin
Software and Sowftware22-Oct-21 0:32
MemberSoftware and Sowftware22-Oct-21 0:32 
AnswerRe: C# Virtual Camera Pin
lmoelleb22-Oct-21 3:30
Memberlmoelleb22-Oct-21 3:30 
AnswerRe: C# Virtual Camera Pin
Gerry Schmitz22-Oct-21 8:37
mveGerry Schmitz22-Oct-21 8:37 
QuestionC# & .Net core new features related articles Pin
Mou_kol19-Oct-21 9:14
MemberMou_kol19-Oct-21 9:14 
AnswerRe: C# & .Net core new features related articles Pin
Richard Andrew x6419-Oct-21 11:48
professionalRichard Andrew x6419-Oct-21 11:48 
AnswerRe: C# & .Net core new features related articles Pin
BillWoodruff21-Oct-21 0:18
mveBillWoodruff21-Oct-21 0:18 
QuestionSend Whatsapp Messages from C# Windows Forms Application Pin
Zeyad Jalil18-Oct-21 2:13
professionalZeyad Jalil18-Oct-21 2:13 
AnswerRe: Send Whatsapp Messages from C# Windows Forms Application Pin
OriginalGriff18-Oct-21 3:22
mveOriginalGriff18-Oct-21 3:22 
GeneralRe: Send Whatsapp Messages from C# Windows Forms Application Pin
Zeyad Jalil18-Oct-21 3:50
professionalZeyad Jalil18-Oct-21 3: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.