Skip to main content

All Questions

Tagged with
0 votes
0 answers
35 views

Return an integer from a Task [duplicate]

I watched this video to create an async function that doesn't block my winforms GUI. C# Async / Await - Make your app more responsive and faster with asynchronous programming That works great and now ...
bjcasey's user avatar
  • 37
1 vote
1 answer
69 views

When using Diagnostics.Process, blocks UI in WinForms C# 5.0

I need to create app that runs different commands (PowerShell.exe, ipconfig, etc.), but when the ExecuteCommand is called the UI freezes until work is finished. Tried to run the method using await ...
Hello World's user avatar
0 votes
2 answers
69 views

How to wait for a function in C# windows application to execute which is getting called from C# API project

I am novice to Task, threads and parallel programming and I tried reading about it but I didn't understand how to fit solution to below problem. Basically I have a Function which is executing on users ...
Abhijit's user avatar
  • 31
0 votes
0 answers
94 views

Main thread errors during executing a thread unsafe program from a responsive Windows Forms app

I would like to call a thread unsafe program asynchronously to avoid blocking the UI (Windows Forms). But my solution sometimes causes main thread problems "The automation program should be re-...
user sy's user avatar
0 votes
0 answers
23 views

Windows Form application with multiple background Tasks?

My question is the following: I have a winform application which does some text file processes in the background and I show the process status on a winform form. There could be 3 background processess ...
Bontoomester's user avatar
1 vote
3 answers
121 views

What mechanism does an async button click handler maintain separate local variables for each invocation?

This code does what you would expect: Two clicks of the button in rapid succession will start two tasks and print two messages with two different local variable values. private bool _dummy; ...
amonroejj's user avatar
  • 633
1 vote
1 answer
50 views

What's the difference between the first method that runs Task.Run and the one which doesn't run Task.Run?

The listenForClients1 method doesn't block the main thread but the listenForClients2 does. Why is there a difference here? Both tasks seems to be executing but the second doesn't begin working on a ...
Gottegubben's user avatar
0 votes
0 answers
26 views

Program crashes sporadically at Controls.Add(Control c) method [duplicate]

I have built a nested user control (framework 4.8) that can hold many child user controls. All squares are part of one user control, that is placed on the "Bord" which is a FlowLayouPanel: ...
mgx's user avatar
  • 21
-3 votes
1 answer
913 views

How to wait until operations within a foreach loop are completed before iterating again in C#? [closed]

I currently am running the following code: async Task Method() { foreach (DataGridViewRow row in dataGridView1.Row) { // Do Something } await Task.Delay(120000); } However ...
T4556's user avatar
  • 1
0 votes
1 answer
100 views

Task returning before its completion

I have desktop application in which I am doing some SQL Server queries asynchronously using ADO.NET. There is one case in which I am creating an object and its taking around 5-6 seconds for completion....
Saghar Francis's user avatar
1 vote
1 answer
105 views

C# Forms App Executing Task.Run stops the rest of the code execution

Excuse for the code it is a mess but I'm trying to figure things out without much use of google. Problem: I have an OnKeyDown method this starts moving my square on the screen to the right, I want to ...
ThisQRequiresASpecialist's user avatar
1 vote
1 answer
289 views

What is causing the deadlock?

I know this is not using the proper form, but can someone tell me why the first code snippet works and the 2nd causes a deadlock? private void button1_Click(object sender, EventArgs e) { textBox1....
MBeckius's user avatar
  • 1,527
2 votes
1 answer
2k views

How do I display the progress of a Task using ProgressBar, Progress, and IProgress<int>

How do I use this? I am working on a program, that focuses on working with files and directories, and displaying information about the files in a DataGridView. That and copying the files, are ...
sJohnson1021's user avatar
1 vote
1 answer
61 views

Need clarification on using Tasks and Threads C#

I have a program where I have multiple devices plugged in via USB and are connected to my program with HIDSharp. The program I have essentially creates multiple instances of "APData" class ...
Steven Villarreal's user avatar
0 votes
0 answers
170 views

Task Cancellation Token Not Being Triggered

I am trying to use tasks to send emails. That part is working but I also want to allow the user to cancel an email before it is sent. Currently I am storing a list of Tasks in a List and when a user ...
Nuvolari's user avatar
  • 1,155

15 30 50 per page
1
2 3 4 5
10