File

projects/wms-framework/src/lib/baseframework/Thread.ts

Description

Replacement for Threading Thread class

Index

Properties
Methods

Constructor

constructor(starter: unknown)

Creates an instance of Thread.

Parameters :
Name Type Optional
starter unknown No

Properties

Starter
Type : unknown

Starter

Methods

Static sleep
sleep(time: number)

This implementation uses javascript promise resolution So it should be preferred to use than the busy wait function

Parameters :
Name Type Optional Description
time number No

time in milliseconds

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 :
Name Type Optional Description
time number No

time in milliseconds

Returns : void
Start
Start(...parameters: any)

Start method Not implemented

Parameters :
Name Type Optional
parameters any No
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');
  }
}

result-matching ""

    No results matching ""