CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
cancellation_token.h
1
2#pragma once
3
4#include <system/object.h>
5#include <system/action.h>
6
7namespace System { namespace Threading {
8
9class CancellationTokenSource;
10class CancellationToken;
11
18class ASPOSECPP_SHARED_CLASS CancellationTokenRegistration
19{
20public:
25 ASPOSECPP_SHARED_API void Dispose();
26
27private:
28 friend class CancellationToken;
29
34 int32_t m_registration = -1;
35};
36
42class ASPOSECPP_SHARED_CLASS CancellationToken : public Details::BoxableObjectBase
43{
44public:
47 ASPOSECPP_SHARED_API CancellationToken();
48
52 static ASPOSECPP_SHARED_API CancellationToken get_None();
53
56 ASPOSECPP_SHARED_API bool get_IsCancellationRequested() const;
61 ASPOSECPP_SHARED_API bool get_CanBeCanceled() const;
62
69 ASPOSECPP_SHARED_API CancellationTokenRegistration Register(const Action<>& callback) const;
70
75 ASPOSECPP_SHARED_API void ThrowIfCancellationRequested() const;
76
77private:
79
83};
84
85}} // System::Threading
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Propagates notification that operations should be canceled. This class provides a mechanism for coope...
Definition: cancellation_token.h:43
static CancellationToken get_None()
Returns an empty System::Threading::CancellationToken value.
void ThrowIfCancellationRequested() const
Throws a OperationCanceledException if cancellation has been requested.
bool get_IsCancellationRequested() const
Gets whether cancellation has been requested for this token.
CancellationTokenRegistration Register(const Action<> &callback) const
Registers a callback that will be invoked when cancellation is requested.
bool get_CanBeCanceled() const
Gets whether this token is capable of being in the canceled state.
CancellationToken()
Default constructor.
Represents a registration for a cancellation token callback.
Definition: cancellation_token.h:19
void Dispose()
Disposes the registration and removes the callback from the associated CancellationTokenSource....
A cancellation token source that can be used to trigger cancellation notifications.
Definition: cancellation_token_source.h:17
Subclass of System::SmartPtr which sets itself to weak mode at construction. Please note that this cl...
Definition: weak_ptr.h:18
Definition: db_command.h:9
MulticastDelegate< void(Args...)> Action
Delegate type that references methods that have no return value.
Definition: action.h:40