When i lunch a function on my .net application, the app seems to be “blocked”. So i ask you: how can limit cpu workload for a particular method ?
The only way is the Application.DoEvents ?
And: what if i use an third party dll that for the same reason (big elaboration) seems to block (not responding) my app ?
EDIT: maybe threading is the answer, but, now, i’ve another question: is it possible to ‘limit’ cpu usage to a thread ?
Run whatever is causing the blocking on a different thread than the main thread.
You can’t limit it for a particular method. Only for a particular thread. And this will not solve the blocking issue.
No, not maybe. It is the answer.
Well, you could try setting
Thread.Priority. Note that the OS does not have to honor the priority that you set (thus, try). Additionally, this just changes the priority for scheduling the thread to execute. If there are no other threads that need CPU time, then of course your thread will still get scheduled on the CPU.