Program won't close fully after closing [closed] - c#

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I have a problem with a project. After I close my program it won't start anymore because it is still half running in the background.
Sideinfos:
I use threads to asynchronously send refreshing values to other clients via multicast.
How can I stop the threads, so they won't run in the background and I can restart the program?

When you start a thread, you can just set the IsBackground property to true so that it does not survive the death of the other threads.
var thread = new Thread(SendAndReceive);
thread.IsBackground = true;
thread.Start();

Related

Using while loop in a command freezes window [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 months ago.
Improve this question
I have a button that executes a command, and it contains a while loop, the application freezes after I start the command, I have also tried to run it recursively but I got the same behavior, and using a timer is not an option, the task can't be called using an interval
You have to run the blocking section of your code in a separate thread. Running it on the main UI thread will freeze the UI.
You can use Tasks to do this.
using System.Threading.Tasks;
Task.Run(() => {
while (condition)
{
// operation
}
});

In C# Form freezes when opened from callback [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I am developing a C# apps with callback functions.
When the app gets a message, a callback function is triggered and opens a form to display the contents of the message. I do that with .Show() and .BringToFront().
But the new form window, that is opened is frozen. I can't click buttons or even close the window. It remains in the background.
Can somebody tell me why this is happening?
I am using visual studio 2019.
The callback function:
public void currentSelectedCharacteristic_ValueChanged3(GattCharacteristic sender, GattValueChangedEventArgs args)
{
Allgemein.HinweisFenster.Show();
Allgemein.HinweisFenster.BringToFront();
}
We need more details to solve. But i can say that there is a process that blocks your main thread. Try to use 'Application.DoEvent();' or move your code that blocks your thread to another thread. And consider using 'background worker' for this.
Please refer to this thread for more details.
You should also consider that for Windows application, you have to be aware of threads manipulation, thus you have always one GUI thread that can be impacted by your calls flow.
So a rule of thumb is to know how your threads work inside your application.
Generally speaking, Frozen windows are often a sign of GUI thread block.

Re-run c# application after delay of 5 seconds [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
On clicking directly my c# application.exe file, i am running my application and its process in task manager appears if that process on certain condition kills my application stops. What i want is to re run the application after delay of 5 seconds by it self.
You cannot. That process is gone. What you can do is start a second process with you first, most commonly called a "watchdog" or "guard", to scan for your first process and if it does not find it, start it. It's not foolproof though, somebody could just as easily kill that process, too. It's just another layer.
Advice on how to implement that is far to broad for this format, I suggest you read some good articles on it, try to implement it and come here when you find yourself stuck at a specific problem.
Although my answer might not be that helpful, and also this question isn't a kind related to coding issues, but I suppose, using Windows Task Scheduler might work out for you, as you can add various triggers to your application and repeat your task after any set amount of time.
Hope it helps. Thanks

All UWP Samples freezing at splash screen [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
All of UWP Samples I have tried to compile and run do not work. They always freeze on splash screen and stay like that. And after shutting them down, I can't run them again because it says System is using the .exe process.
Have you tried to turn off your Anti-Virus?
In my case, Avast sometimes blocks my executable, so I have to disable it.

Program Freezes When Running Lengthy Task [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Maybe it’s a novice question, but I a am a novice. I have a program which does a lengthy task, while it does it, the form stays frozen, if its minimized it can't be maximized Etc. How can I fix that.
Also, the program runs in a loop, and in each iteration prints info to a list box, line by line. Problem is, the list box doesn't get written, untill after the whole loop finishes. How can I correct that.
You can use either a Thread or a BackgroundWorker to do your work.
Calling lengthy code from the UI will block the UI thread and the app 'freezes'.

Categories

Resources