Fixed documentation of Waitable and Request classes; wrote down some ideas to improve the request framework
git-svn-id: file:///srv/devel/repo-conversion/nusu@75 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
73ef5de576
commit
e0cf91a0a4
4 changed files with 88 additions and 21 deletions
68
Documents/Request Framework.txt
Normal file
68
Documents/Request Framework.txt
Normal file
|
@ -0,0 +1,68 @@
|
|||
The request framework should not require that .NET multithreading is used for
|
||||
asynchronous requests.
|
||||
|
||||
Otherwise, it would prvent overlapped operations, 3rd party APIs (eg. used
|
||||
via P/Invoke) from being able to use the request framework and possibly even
|
||||
spawn duplicate implementations.
|
||||
|
||||
|
||||
Design using interfaces:
|
||||
|
||||
interface IWaitable {
|
||||
|
||||
/// <summary>Fired when the background process has finished</summary>
|
||||
/// <remarks>
|
||||
/// If the process is already finished when a client registers to this event,
|
||||
/// the registered callback will be invoked synchronously right when the
|
||||
/// registration takes place.
|
||||
/// </remarks>
|
||||
event EventHandler Finished;
|
||||
|
||||
/// <summary>Waits until the background process finishes</summary>
|
||||
void Wait();
|
||||
|
||||
/// <summary>Waits until the background process finishes or a timeout occurs</summary>
|
||||
/// <param name="timeoutMilliseconds">
|
||||
/// Number of milliseconds after which to stop waiting and return immediately
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// True if the background process completed, false if the timeout was reached
|
||||
/// </returns>
|
||||
bool Wait(int timeoutMilliseconds);
|
||||
|
||||
/// <summary>Whether the background process has finished</summary>
|
||||
bool Finished { get; }
|
||||
|
||||
}
|
||||
|
||||
interface IThreadedWaitable : IWaitable {
|
||||
|
||||
WaitHandle WaitHandle { get; }
|
||||
|
||||
}
|
||||
|
||||
interface IRequest : IWaitable {
|
||||
|
||||
/// <summary>
|
||||
/// Waits for the background process to complete and re-throws the exception to
|
||||
/// the caller when an error has occured
|
||||
/// </summary>
|
||||
void Join();
|
||||
|
||||
}
|
||||
|
||||
interface IRequest<ResultType> : IRequest {
|
||||
|
||||
/// <summary>
|
||||
/// Waits for the background process to complete and re-throws the exception to
|
||||
/// the caller when an error has occured
|
||||
/// </summary>
|
||||
/// <returns>The result of the background processing</returns>
|
||||
new ResultType Join();
|
||||
|
||||
}
|
||||
|
||||
interface IThreadedRequest : IRequest, IThreadedWaitable { }
|
||||
|
||||
interface IThreadedRequest<ResultType> :
|
||||
IRequest<ResultType>, IThreadedRequest, IThreadedWaitable { }
|
Loading…
Add table
Add a link
Reference in a new issue