Quantcast
Channel: Task Scheduler Managed Wrapper
Viewing all articles
Browse latest Browse all 2206

Commented Unassigned: COMException with RunningTask.Refresh() [12470]

$
0
0
I want check task state and i write code
```
RunningTask rt = task.Run();
do
{
Thread.Sleep(1000);
} while (rt.State == TaskState.Running);
```
However, I have infinite loop, because state is not updated (running always). When I change cycle body to
```
do
{
Thread.Sleep(1000);
rt.Refresh(); // COMException here
} while (rt.State == TaskState.Running);
```
Code fires exception if state change from Running to Unknown.

It is correct behaviour?

P.S. In the end, i write first cycle version with
```
while (task.State == TaskState.Running);
```
and I do not have problems.
Comments: ** Comment from web user: _r_m_ **

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Win32.TaskScheduler.dll
HRESULT: 0x8004130B

Thanks for TaskEventWatcher, I will try it.

OT: How soon you move this project on github?


Viewing all articles
Browse latest Browse all 2206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>