- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 9
promise
        mtanksl edited this page Mar 6, 2025 
        ·
        3 revisions
      
    Instead of using .NET's Task Parallel Library, I'll be using my own custom class to represent asynchronous operation. It's all wrapped in the Promise and PromiseResult<> classes. If you know how to use .NET's Task and Task<> classes, it is the same.
For performance reasons and for simplicity. The Promise class is lighter and simpler. When a scheduled event is needed, it will be automatically dispatched to the server's scheduler thread. Once it expires, it will automatically dispatch all the actions to the main server's (single thread) dispatcher thread. We don't want to deal with concurrency problems, do we?
//...
Promise.Delay("CancellationKey", TimeSpan.FromSeconds(10) ).Then( () =>
{
	//...
	return Promise.Completed;
} );or
public async Promise SomeMethod()
{
	//...
	await Promise.Delay("CancellationKey", TimeSpan.FromSeconds(10) );
	//...
}