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'.
Related
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 1 year ago.
Improve this question
Hello I have a console application and every time the user types something and enters it closes it and I dont really want that in my application since it needs multiple inputs. I've tried debugging and opening the file itself.
Is there a answer?
-HoverNot
A console application closes when it runs out of code to execute
You can halt until someone has pressed enter by asking for input:
Console.ReadLine()
If you want to force the program to keep waiting for input, you can use
while(true) {
Console.ReadLine()
}
Then the window won't close until you press ctrl-c or click the cross (or kill the process some other way)
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
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 5 years ago.
Improve this question
I'm writing a c# console application and I want it to monitor all keyboard input, even when other programs have focus, so that if a person hits a specific key combination (from anywhere), my code will be activated.
Currently when I run my program and then select another program, my program does not do anything when I enter the key combination.
A thread might be a good idea.
Sorry for my grammar and English. I try to explain it good.
Console application is not suitable for that. you should be looking for Keyboard Hook.
Have a look at this question.
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 6 years ago.
Improve this question
I'm looking for a way to deal with threads (I guess using semaphors) to stop all threads from entering a certain region for a while. When all threads that are currently in the region get out of it (so no thread is in it anymore), I want to do something that affects this region. After that, the region should be enterable by many threads at the same time again.
I don't see how to do it with the Semaphore since in the documentation I can't find any properties which f.e. Let me change its property on how many can enter the region and even get the amount how many are inside at all.
How could I do this?
Sounds bit like you looking for ReaderWriterLockSlim class. Many thread can enter/get read lock, but only one thread can get write lock.
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 6 years ago.
Improve this question
I have an application developed in C # that sometimes is blocked, when it is blocked I have to restart it. I know if there is any way to detect if the application is frozen, close it and then restart.
Thank for all!
Since it could be a third party programm you want to restart:
You restart a process in C# like so:
Process[] procs;
procs = Process.GetProcessesByName("Name");
// Test to see if the process is not responding.
if (!procs[0].Responding)
{
procs[0].CloseMainWindow();
procs[0].WaitForExit();
procs[0].Start();
}
Otherwise please follow the hints provided in the comments.