projects/wms-framework/src/lib/baseframework/Thread.ts
Replacement for Threading Thread class
Properties |
Methods |
constructor(starter: unknown)
|
||||||
Creates an instance of Thread.
Parameters :
|
Starter |
Type : unknown
|
Starter |
Static sleep | ||||||||
sleep(time: number)
|
||||||||
This implementation uses javascript promise resolution So it should be preferred to use than the busy wait function
Parameters :
Returns :
Promise<void>
{Promise |
Static Sleep | ||||||||
This should be changed to a setTimeout in migrated code | ||||||||
Sleep(time: number)
|
||||||||
Thread Sleep methods Blocks the current JS thread for a specific amount of time This is a busy wait implementation. It should be modified on migrated code.
Parameters :
Returns :
void
|
Start | ||||||
Start(...parameters: any)
|
||||||
Start method Not implemented
Parameters :
Returns :
any
{*} |
import { Debugger } from '../diagnostics/Debugger';
/**
* Replacement for Threading Thread class
*
* @export
* @class Thread
* @wType System.Threading.Thread
* @wNetSupport
*/
export class Thread {
/**
* Creates an instance of Thread.
* @param {*} starter
* @memberof Thread
*/
constructor(starter: unknown = undefined) {
this.Starter = starter;
}
/**
* Starter
*
* @type {unknown}
* @memberof Thread
* @wIgnore
*/
Starter: unknown;
/**
* Thread Sleep methods
* Blocks the current JS thread for a specific amount of time
*
* This is a busy wait implementation. It should be modified on migrated code.
*
* @param {number} time time in milliseconds
* @memberof Thread
* @deprecated This should be changed to a setTimeout in migrated code
*/
static Sleep(time: number): void {
const waitTill = new Date(new Date().getTime() + time);
while (waitTill > new Date()) {
// do nothing keep the thread busy until the timeout
}
}
/**
* This implementation uses javascript promise resolution
* So it should be preferred to use than the busy wait function
*
* @param {number} time time in milliseconds
* @return {*} {Promise<void>}
* @memberof Thread
*/
static sleep(time: number): Promise<void> {
const result = new Promise<void>((resolve) => {
setTimeout(resolve, time);
});
return result;
}
/**
* Start method
* Not implemented
*
* @param {*} parameters
* @return {*} {*}
* @memberof Thread
* @wNoMap
*/
Start(...parameters: any): any {
Debugger.Throw('Not implemented');
}
}