1c how to find out about the execution of the wait handler. "blinking" the interface, or chains of asynchronous calls

Code 1C v 8.2 UP Connect Handler Expectations (<ИмяПроцедуры>, <Интервал>, <Однократно>)
Options:
<ИмяПроцедуры>
<Интервал>(required) Type: Number. Time interval, in seconds, with an accuracy of 1/10 of a second, after which the procedure will be called (positive number). If a value is specified less than 1, then the value of the third parameter must be True.
<Однократно>(optional) Type: Boolean. The flag of one-time execution of the wait handler.
True - The specified wait handler will be executed once. Default value: False
Description: Attaches the specified procedure as a wait handler. The procedure will be called while the system is waiting every time after the specified time interval.

Availability:
Thin client, web client, thick client.

Note:
The call to the wait handler continues until the form is closed or until the form's DisableWaitHandler is called. Code 1C v 8.2 UE DisableWaitingHandler (<ИмяПроцедуры>)

Code 1C v 8.2 UP
& OnClient
WrapperHandler () Procedure
ProcessWaiting ();
End of Procedure

&On server
Procedure Process Waiting ()
// do whatever is required
End of Procedure

//....
ConnectWaitingHandler ("HandlerShell", 3, True);

<ИмяПроцедуры>, <Интервал>, <Однократно>)
Connects a call to the specified procedure of a managed application module (regular application module) or a global common module at a specified time interval. The call will be made only in the "rest state", that is, at the moment when the program does not perform any action. The call to the wait handler continues until the system shuts down or until the DisableWaitHandler global context method is called.
Code 1C v 8.x Procedure Sales Report Per Day ()
// ...
End of Procedure

//...
ConnectWaitingHandler ("ReportOverDaySales", 60); // every minute
Code 1C v 8.x // In standard checks dyn. configuration updates every 20 min.
ConnectWaitingHandler ("WaitingHandlerDynamicChangingIBCheckWaiting", 20 * 60);
// connect a data exchange handler
ConnectWaitingHandler ("DataExchangeCheck", chapVariableValue ("chapNumber ofExchangePolishSeconds"));
ConnectWaitingHandler ("Check RepliesOnConnectionApplication", 86400); // = 24 (h) * 60 (min) * 60 (sec) = 1 day

For Form
Code 1C v 8.x ConnectWaitingHandler (<ИмяПроцедуры>, <Интервал>, <Однократно>)
Options:
<ИмяПроцедуры>(required) Type: String. The name of the procedure to hook up as a wait handler.
<Интервал>(required) Type: Number. Time interval, in seconds, with an accuracy of 1/10 of a second, after which the procedure call will be made (positive number). If the specified value is less than 1, then the value of the third parameter must be True.
<Однократно>(optional) Type: Boolean. The flag of one-time execution of the wait handler. 0 True - The specified wait handler will be executed once. Default value: False

Description:
Attaches the specified procedure as a wait handler. The procedure will be called while the system is waiting every time after the specified time interval.

Availability:
Thick client.
Note:
The call to the wait handler continues until the form is closed or until the form's DisableWaitHandler is called.
Example:
Code 1C v 8.x ConnectWaitingHandler ("Waiting", 1);
Code 1C v 8.x Form. Autosave Interval = 300; // 5 minutes
If Form.AutoSave Interval<>0 Then
Form.ConnectWaitingHandler ("EventHandlerByTimer", Integer (Form.AutoSaveInterval * 60));
EndIf;

Waiting processing in the 1C: Enterprise system, as follows from the documentation, is intended for periodic execution of the global module procedure at a specified time interval. The code to run will look like this:
Code 1C v 7.x Expectation Processing ("RefreshCounter _", 1);
Where "RefreshCounter_"- the name of the procedure of the global module, which will be launched with a frequency of 1 second. (second parameter equal to 1)

But! The problem is that you can only run wait processing once. Restarting will cancel the previous one. In other words, if you want to make, for example, a timer processing for counting the elapsed time, then you can start only one timer, because starting the second timer will stop the first. But what if you need to start 2, 3 or more of these timers at the same time? Or do you still need to periodically scan the status of documents?

There is an exit! Wait processing must be started in the context of the form to decouple this thread from the global context. And then it will be possible to periodically start the procedure of the local module, i.e. procedure located in the module of your processing form.

The code to run will look like this:
Code 1C v 7.x Form.Waiting Processing ("RefreshCounter _", 1);
Where "RefreshCounter_"- the name of the procedure of the local module of the processing form, which will be launched with a frequency of 1 second. (second parameter equal to 1)
Thus, in each processing, you can start your own wait processing, which will work as long as the form is open.

In forms you can use Code 1C v 8.х Form.Waiting Processing ("ProcedureName", Startup Time),
where ProcedureName is the name of the procedure that starts after Startup Time seconds
In the procedure itself, you need to insert the Code 1C v 8.x Form.Waiting Processing ("ProcedureName", 0) to stop waiting processing (of course, after the necessary conditions are met).
A source

Code 1C v 8.2 UP Connect Handler Expectations (<ИмяПроцедуры>, <Интервал>, <Однократно>)
Options:
<ИмяПроцедуры>
<Интервал>(required) Type: Number. Time interval, in seconds, with an accuracy of 1/10 of a second, after which the procedure will be called (positive number). If a value is specified less than 1, then the value of the third parameter must be True.
<Однократно>(optional) Type: Boolean. The flag of one-time execution of the wait handler.
True - The specified wait handler will be executed once. Default value: False
Description: Attaches the specified procedure as a wait handler. The procedure will be called while the system is waiting every time after the specified time interval.

Availability:
Thin client, web client, thick client.

Note:
The call to the wait handler continues until the form is closed or until the form's DisableWaitHandler is called. Code 1C v 8.2 UE DisableWaitingHandler (<ИмяПроцедуры>)

Code 1C v 8.2 UP
& OnClient
WrapperHandler () Procedure
ProcessWaiting ();
End of Procedure

&On server
Procedure Process Waiting ()
// do whatever is required
End of Procedure

//....
ConnectWaitingHandler ("HandlerShell", 3, True);

<ИмяПроцедуры>, <Интервал>, <Однократно>)
Connects a call to the specified procedure of a managed application module (regular application module) or a global common module at a specified time interval. The call will be made only in the "rest state", that is, at the moment when the program does not perform any action. The call to the wait handler continues until the system shuts down or until the DisableWaitHandler global context method is called.
Code 1C v 8.x Procedure Sales Report Per Day ()
// ...
End of Procedure

//...
ConnectWaitingHandler ("ReportOverDaySales", 60); // every minute
Code 1C v 8.x // In standard checks dyn. configuration updates every 20 min.
ConnectWaitingHandler ("WaitingHandlerDynamicChangingIBCheckWaiting", 20 * 60);
// connect a data exchange handler
ConnectWaitingHandler ("DataExchangeCheck", chapVariableValue ("chapNumber ofExchangePolishSeconds"));
ConnectWaitingHandler ("Check RepliesOnConnectionApplication", 86400); // = 24 (h) * 60 (min) * 60 (sec) = 1 day

For Form
Code 1C v 8.x ConnectWaitingHandler (<ИмяПроцедуры>, <Интервал>, <Однократно>)
Options:
<ИмяПроцедуры>(required) Type: String. The name of the procedure to hook up as a wait handler.
<Интервал>(required) Type: Number. Time interval, in seconds, with an accuracy of 1/10 of a second, after which the procedure call will be made (positive number). If the specified value is less than 1, then the value of the third parameter must be True.
<Однократно>(optional) Type: Boolean. The flag of one-time execution of the wait handler. 0 True - The specified wait handler will be executed once. Default value: False

Description:
Attaches the specified procedure as a wait handler. The procedure will be called while the system is waiting every time after the specified time interval.

Availability:
Thick client.
Note:
The call to the wait handler continues until the form is closed or until the form's DisableWaitHandler is called.
Example:
Code 1C v 8.x ConnectWaitingHandler ("Waiting", 1);
Code 1C v 8.x Form. Autosave Interval = 300; // 5 minutes
If Form.AutoSave Interval<>0 Then
Form.ConnectWaitingHandler ("EventHandlerByTimer", Integer (Form.AutoSaveInterval * 60));
EndIf;

Waiting processing in the 1C: Enterprise system, as follows from the documentation, is intended for periodic execution of the global module procedure at a specified time interval. The code to run will look like this:
Code 1C v 7.x Expectation Processing ("RefreshCounter _", 1);
Where "RefreshCounter_"- the name of the procedure of the global module, which will be launched with a frequency of 1 second. (second parameter equal to 1)

But! The problem is that you can only run wait processing once. Restarting will cancel the previous one. In other words, if you want to make, for example, a timer processing for counting the elapsed time, then you can start only one timer, because starting the second timer will stop the first. But what if you need to start 2, 3 or more of these timers at the same time? Or do you still need to periodically scan the status of documents?

There is an exit! Wait processing must be started in the context of the form to decouple this thread from the global context. And then it will be possible to periodically start the procedure of the local module, i.e. procedure located in the module of your processing form.

The code to run will look like this:
Code 1C v 7.x Form.Waiting Processing ("RefreshCounter _", 1);
Where "RefreshCounter_"- the name of the procedure of the local module of the processing form, which will be launched with a frequency of 1 second. (second parameter equal to 1)
Thus, in each processing, you can start your own wait processing, which will work as long as the form is open.

In forms you can use Code 1C v 8.х Form.Waiting Processing ("ProcedureName", Startup Time),
where ProcedureName is the name of the procedure that starts after Startup Time seconds
In the procedure itself, you need to insert the Code 1C v 8.x Form.Waiting Processing ("ProcedureName", 0) to stop waiting processing (of course, after the necessary conditions are met).
A source

The 1C platform provides us with the capabilities of asynchronous procedure calls, which, at times, can be used for simple but fun things. For example, you can "blink" everything that has a color or any possibility of changing the visual design. Moreover, you can use both a simpler but uncontrolled mechanism, or design an interesting chain of asynchronous calls and set its preferred behavior.

We are talking here, of course, about the AttachWaitingHandler () procedure.

Let me remind you the syntax of the procedure:

ConnectWaitingHandler (<ИмяПроцедуры>, <Интервал>, <Однократно>)

Moreover, if you specify an interval of less than a second, the start of the procedure must be one-time. This is where we lose control over the flow of execution and lose the ability to "customize" it (flexibly, individually).

But this limitation is easily circumvented.

In order not to spread the thought along the tree, I will immediately give a simple example and explain it.

Let's say we have a spreadsheet document on the form and we want to "blink" 5 times with some of its area.

//////////////////// // // // // // ///////// // // /////////// ///////// & OnClient Procedure Blink Area (Command) mf Blink Time = 3; // Counter. Form attribute, "visible" in the procedures of wait handlers ConnectWaitingHandler ("ShowAreaSelection", 0.1, True); // You can also directly call EndProcedure & On the Client Procedure ShowSelectionArea () Area = Object.TD.Area (mfFirstDataString, mfFirstDataColumn, mfLastDataRow, mfLastDataColumn); Border = New Line (TabularDocumentCellLineType.Double); Region.Circle (Border, Border, Border, Border); // Outline the area with mfSpeedBlink = mfSwinkMow - 1; // Decrement the counter ConnectWaitingHandler ("RemoveAreaSelection", 0.5, True); // Connect the chain of asynchronous calls EndProcedure & At the Client Procedure RemoveSelectionArea () Area = Object.TD.Area (mfFirstDataString, mfFirstDataColumn, mfLastDataRow, mfLastDataColumn); Border = New Line (TabularDocumentCellLineType.NoLine); Region.Circle (Border, Border, Border, Border); // Remove the outline of the area If mfSkink> 0 Then ConnectWaitingHandler ("ShowAreaSelection", 0.5, True); // Repeat as long as there is left in the counter EndIf; End of Procedure

The main requirement is only that the counter variable mfHow to Blink is "visible" from the procedures that we run asynchronously. V this case variable is a form attribute.

An attentive reader might have noticed that with the formation of such chains, we kill two birds with one stone:

  • We bypass the restriction on the repeatability of procedure calls with interval values ​​less than a second;
  • We have the ability to form chains of different lengths and complexity:
    • connect a wait handler directly in the wait handler procedure itself;
    • make such procedures connect to each other;
    • organize a more complex structure of call chains;
    • infinitely complicate the variability of call management (for example, change inside calls not only their counters, but also the values ​​of intervals, styles of design (so that a rainbow shimmers 🌈).

Despite the simplicity of the described method, there is considerable potential hidden in it.

In 2017, it is more flexible to control the behavior of the program - this is modern.