Avoid suspension while a thread is running

  • Thread starter Thread starter Zeno Loco
  • Start date Start date
Z

Zeno Loco

Hi,

in my application I have some thread operations (TCP file transfer)
that sometimes goes in error because of device suspension.
How can I avoid this problem?

Thanks
 
You should add exception handling to tray the condition and either retry or
abort the operation.
 
Thanks Chris,

but my idea is to avoud the suspension (as in the subject)

.. intercepting an event "before suspend" or something similar and
cancel it

or

.. turning off the suspension when I start transmission and turning it
on at the end.

Do you know if this is possible?
 
You can't. You can avoid suspend due to idle by periodically P/Invoking
SystemIdleTimerReset, but there's no way for you to intercept or stop the
user from pressing the power button. You must assume it will happen and
code defensively.
 
Back
Top