Delay

Description

An opaque awaitable type, specifically used in coroutines, representing an abstract delay time.

await Delay(5); // awaits 5 model time units
var delay = Delay.seconds(22); // represents a 22 second delay
await delay; // wait for 22 seconds
await delay; // wait again for another 22 seconds
		

A Delay represents an 'abstract' delay time in that the suspend/resume mechanism is not started when the Delay object is created, but each time the await statement is invoked, resulting in possibly multiple different delay actions.

Constructor

Delay Returns a delay object representing a delay time in model time units.

Static Methods

days Returns a delay object representing a delay time in days.
hours Returns a delay object representing a delay time in hours.
minutes Returns a delay object representing a delay time in minutes.
realTime Returns a delay object representing a real-time delay in seconds.
seconds Returns a delay object representing a delay time in seconds.

Details

Do no remove, this fixes the anchor on doc.flexsim.com

Delay Constructor

Delay( double timeUnits )

Parameters

timeUnits The number of model time units to delay.

Returns

Delay The resulting delay.

Description

Returns a delay object representing a delay time in model time units.

await Delay(5);
Do no remove, this fixes the anchor on doc.flexsim.com

Delay.days()

static Delay days( double numDays )

Parameters

numDays The number of days to delay.

Returns

Delay The resulting delay.

Description

Returns a delay object representing a delay time in days.

await Delay.days(5);
Do no remove, this fixes the anchor on doc.flexsim.com

Delay.hours()

static Delay hours( double numHours )

Parameters

numHours The number of hours to delay.

Returns

Delay The resulting delay.

Description

Returns a delay object representing a delay time in hours.

await Delay.hours(5);
Do no remove, this fixes the anchor on doc.flexsim.com

Delay.minutes()

static Delay minutes( double numMinutes )

Parameters

numMinutes The number of minutes to delay.

Returns

Delay The resulting delay.

Description

Returns a delay object representing a delay time in minutes.

await Delay.minutes(5);
Do no remove, this fixes the anchor on doc.flexsim.com

Delay.realTime()

static Delay realTime( double numSeconds )

Parameters

numSeconds The number of real-time seconds to delay.

Returns

Delay The resulting delay.

Description

Returns a delay object representing a real-time delay in seconds.

await Delay.realTime(0);

This is mostly used as part of UI development by FlexSim developers, but it is nevertheless available to users. You should not use this in your simulation logic or else you will have repeatability issues. Rather, awaiting real time delays can be useful for things like auto-build scripts. It allows you to execute logic asynchronously. Awaiting a real time delay of 0 will post a message to FlexSim's message queue. The logic that called the FlexScript code will finish, and when FlexSim continues processing its message queue and reaches the posted message, it will then resume the coroutine. If you await a real time delay greater than 0, then FlexSim will create a platform-dependent timer, will wait the defined time, and then will resume the coroutine.

Do no remove, this fixes the anchor on doc.flexsim.com

Delay.seconds()

static Delay seconds( double numSeconds )

Parameters

numSeconds The number of seconds to delay.

Returns

Delay The resulting delay.

Description

Returns a delay object representing a delay time in seconds.

await Delay.seconds(5);