Hi,
I have an import of an CSV file into a SQL database (some 10000 records). At the moment, it's done in Main and full of DoEvents -> bad thing.
So I tried to put the import code in a Service.
But - the service runs in the same thread as the UI, so I have nothing won. I still have to do something to keep the UI working.
There are some possibilities:
- Use Async methods, wherever possible. That's nice, when it possible.
- Use sleep(0) - see my following question
- Put the long running things in another thread
What are the pros and cons of the different possibilities?
Concerning sleep(0): What are the performance impacts of that? Let's say, I have a calculation, no chance to do async, perhaps some 100000 iterations. What when I sleep(0) every iteration? Every X iterations? Are there criteria I could use?
I have an import of an CSV file into a SQL database (some 10000 records). At the moment, it's done in Main and full of DoEvents -> bad thing.
So I tried to put the import code in a Service.
But - the service runs in the same thread as the UI, so I have nothing won. I still have to do something to keep the UI working.
There are some possibilities:
- Use Async methods, wherever possible. That's nice, when it possible.
- Use sleep(0) - see my following question
- Put the long running things in another thread
What are the pros and cons of the different possibilities?
Concerning sleep(0): What are the performance impacts of that? Let's say, I have a calculation, no chance to do async, perhaps some 100000 iterations. What when I sleep(0) every iteration? Every X iterations? Are there criteria I could use?