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.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
As part of a program, there are situations in which the user has to be quickly notified that something is going on.
I was thinking of using Notify Icons. For some reason, they appear but don't dissapear automatically as I expected. (As in toasts in other platforms)
Then I found the status strip. Which seems convenient too and simpler to program although I have to manually remove the message
or should I go for the old MessageBox as I have been doing so far.
what are the pros or cons on using those methods of communication with the user?
Depending on your usecase and the importance of your message to the user you'll have to consider the following points:
Is the message important enough to stop the users current workflow immediately, like a messagebox does?
Is it okay, if the users misses a message, because it disappears automatically after a certain amount of time?
A messagebox is clearly the most intruding way of communicating with the user. The status strip on the other hand can easily be missed. Notification Icons including a balloon tooltip are somewhere inbetween. The ballon will most certainly close after a few seconds. But you could also add a timer to remove the notification icon itself after a certain amount of time, too.
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 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'.
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 9 years ago.
Improve this question
I have a requirement to load a file containing up to 1 million lines of string data. My first thought is to use C# 5.0 async to load the data whilst not blocking the UI thread. If the user tries to access something that relies on the data they will get a loading message.
Still I would like the fastest possible method in order to improve the user's experience.
Is the speed of reading data from the disk purely a function of the disk speed and thus StreamReader.ReadAllLines() is as performant as other c# code? Or is there something 'fancy' I can do to boost performance programmatically. This does not have to be described in detail. If so what approximate percentage improvement might be achieved?
I am purely interested in read speed and not concerned with the speed of code that may process the data once loaded.
First of all, take a look on File size, here is detailed Performance measurements
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 8 years ago.
Improve this question
I was asked this question in an interview and still not sure what the correct answer is. The question was:
"If you have a live streaming feed of data that needs to be passed from the background thread to the UI, how do you resolve latency issues between the 2 threads?"
I have read about different types of locks, where multiple threads can access an object simultaneously, however I'm not sure if this is correct as a lock might not be needed. You could just put the data on the dispatcher to send it to the UI.
Does anyone know the answer to this?
I believe the right response for this question is: What latency issues?
It's impossible to answer this question without more information - how the two threads communicate, and what latency issues exist.