DotNetDupe
4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Toggle main menu visibility
Loading...
Searching...
No Matches
Task.h
Go to the documentation of this file.
1
3
4
#pragma once
5
6
#include "
Common.h
"
7
#include "
System/Object.h
"
8
#include "
System/Action.h
"
9
#include "
System/SmartPointer.h
"
10
#include "
System/Threading/ManualResetEvent.h
"
11
#include "
System/Threading/CriticalSection.h
"
12
#include "
System/Threading/Tasks/TaskStatus.h
"
13
14
namespace
DotNetDupe
{
15
namespace
System
{
16
namespace
Threading
{
17
namespace
Tasks
{
18
27
class
Task
:
public
Object
{
28
public
:
31
DOTNETDUPE_API
Task
(
Action<>
objAction);
32
34
DOTNETDUPE_API
virtual
~Task
();
35
37
DOTNETDUPE_API
void
Start
();
38
40
DOTNETDUPE_API
void
Wait
();
41
45
DOTNETDUPE_API
bool
Wait
(
int
iMillisecondsTimeout);
46
49
DOTNETDUPE_API
TaskStatus
GetStatus
()
const
;
50
53
DOTNETDUPE_API
bool
GetIsCompleted
()
const
;
54
57
DOTNETDUPE_API
bool
GetIsFaulted
()
const
;
58
61
DOTNETDUPE_API
bool
GetIsCanceled
()
const
;
62
66
DOTNETDUPE_API
static
SmartPointer<Task>
Run
(
Action<>
objAction);
67
68
private
:
69
Action<>
m_objAction;
70
TaskStatus
m_eStatus;
71
SmartPointer<ManualResetEvent>
m_pCompletionEvent =
nullptr
;
72
mutable
CriticalSection
m_csSync;
73
74
void
Execute();
75
static
void
ThreadPoolCallback(
Object
* pState);
76
77
static
void
RetainTask(
SmartPointer<Task>
pTask);
78
static
void
ReleaseTask(
Task
* pTask);
79
};
80
81
}
82
}
83
}
84
}
Action.h
Encapsulates a delegate method that has parameters and returns void.
Common.h
Defines common cross-platform macros, export decorators, and fundamental types.
DOTNETDUPE_API
#define DOTNETDUPE_API
Platform-specific linkage decoration for exporting or importing library symbols.
Definition
Common.h:20
CriticalSection.h
Provides a re-entrant mutual exclusion primitive for thread synchronization.
ManualResetEvent.h
Notifies one or more waiting threads that an event has occurred.
Object.h
Base object class for DotNetDupe mirroring .NET System.Object.
SmartPointer.h
Provides reference-counted and weak pointer memory management primitives ensuring zero raw ownership.
TaskStatus.h
Represents the current stage in the lifecycle of an asynchronous Task.
DotNetDupe::System::Action<>
Definition
Action.h:51
DotNetDupe::System::Object
Supports all classes in the DotNetDupe class hierarchy.
Definition
Object.h:18
DotNetDupe::System::SmartPointer
A unified smart pointer that supports both unique and shared ownership semantics.
Definition
SmartPointer.h:72
DotNetDupe::System::Threading::CriticalSection
Provides a re-entrant mutual exclusion primitive for thread synchronization.
Definition
CriticalSection.h:19
DotNetDupe::System::Threading::Tasks::Task::Wait
void Wait()
Waits indefinitely for the Task to complete execution.
Definition
Task.cpp:43
DotNetDupe::System::Threading::Tasks::Task::GetIsCompleted
bool GetIsCompleted() const
Gets whether this Task has completed.
Definition
Task.cpp:63
DotNetDupe::System::Threading::Tasks::Task::Task
Task(Action<> objAction)
Initializes a new Task with the specified action delegate.
Definition
Task.cpp:19
DotNetDupe::System::Threading::Tasks::Task::GetIsCanceled
bool GetIsCanceled() const
Gets whether this Task instance has completed execution due to being canceled.
Definition
Task.cpp:77
DotNetDupe::System::Threading::Tasks::Task::Run
static SmartPointer< Task > Run(Action<> objAction)
Queues the specified work to run on the ThreadPool and returns a Task representing that work.
Definition
Task.cpp:83
DotNetDupe::System::Threading::Tasks::Task::Start
void Start()
Starts the Task, scheduling it for execution to the ThreadPool.
Definition
Task.cpp:29
DotNetDupe::System::Threading::Tasks::Task::GetStatus
TaskStatus GetStatus() const
Gets the TaskStatus of this task.
Definition
Task.cpp:57
DotNetDupe::System::Threading::Tasks::Task::GetIsFaulted
bool GetIsFaulted() const
Gets whether the Task completed due to an unhandled exception.
Definition
Task.cpp:71
DotNetDupe::System::Threading::Tasks
Definition
Task.h:17
DotNetDupe::System::Threading::Tasks::TaskStatus
TaskStatus
Represents the current stage in the lifecycle of a Task.
Definition
TaskStatus.h:12
DotNetDupe::System::Threading
Definition
AbandonedMutexException.h:11
DotNetDupe::System
Definition
Action.h:11
DotNetDupe
Definition
IServiceCollection.h:7
Include
System
Threading
Tasks
Task.h
Generated by
1.18.0