@@ -106,6 +106,7 @@ var bot = BotBaseBuilder
106106 })
107107 .NoSerialization ()
108108 .UseEnglish ()
109+ .UseSingleThread ()
109110 .Build ();
110111
111112// Upload bot commands to BotFather
@@ -126,8 +127,32 @@ like ChatId and other stuff your carrying.
126127From there you build up your bots:
127128
128129``` csharp
129- public class StartForm : FormBase
130+ public class Start : FormBase
130131{
132+
133+ public Start ()
134+ {
135+ // Additional event handlers
136+ Init += Start_Init ;
137+ Opened += Start_Opened ;
138+ Closed += Start_Closed ;
139+ }
140+
141+ // Gets invoked on initialization, before navigation
142+ private async Task Start_Init (object sender , Args.InitEventArgs e )
143+ {
144+ }
145+
146+ // Gets invoked after opened
147+ private async Task Start_Opened (object sender , EventArgs e )
148+ {
149+ }
150+
151+ // Gets invoked after form has been closed
152+ private async Task Start_Closed (object sender , EventArgs e )
153+ {
154+ }
155+
131156 // Gets invoked during Navigation to this form
132157 public override async Task PreLoad (MessageResult message )
133158 {
@@ -224,6 +249,7 @@ var bot = BotBaseBuilder
224249 })
225250 .NoSerialization ()
226251 .UseEnglish ()
252+ .UseSingleThread ()
227253 .Build ();
228254
229255bot .BotCommand += async (s , en ) =>
@@ -264,15 +290,15 @@ public class SimpleForm : AutoCleanForm
264290{
265291 public SimpleForm ()
266292 {
267- this . DeleteSide = TelegramBotBase . Enums . eDeleteSide .Both ;
268- this . DeleteMode = TelegramBotBase . Enums . eDeleteMode .OnLeavingForm ;
293+ DeleteSide = EDeleteSide .Both ;
294+ DeleteMode = EDeleteMode .OnLeavingForm ;
269295
270- this . Opened += SimpleForm_Opened ;
296+ Opened += SimpleForm_Opened ;
271297 }
272298
273299 private async Task SimpleForm_Opened (object sender , EventArgs e )
274300 {
275- await this . Device .Send (" Hello world! (send 'back' to get back to Start)\r\n Or\r\n hi, hello, maybe, bye and ciao" );
301+ await Device .Send (" Hello world! (send 'back' to get back to Start)\r\n Or\r\n hi, hello, maybe, bye and ciao" );
276302 }
277303
278304 public override async Task Load (MessageResult message )
@@ -310,7 +336,13 @@ public class SimpleForm : AutoCleanForm
310336``` csharp
311337public class ButtonTestForm : AutoCleanForm
312338{
313- public override async Task Opened ()
339+ public ButtonTestForm ()
340+ {
341+ this .DeleteMode = eDeleteMode .OnLeavingForm ;
342+ Opened += ButtonTestForm_Opened ;
343+ }
344+
345+ private async Task ButtonTestForm_Opened (object sender , EventArgs e )
314346 {
315347 await this .Device .Send (" Hello world! (Click 'back' to get back to Start)" );
316348 }
@@ -380,9 +412,10 @@ public class ProgressTest : AutoCleanForm
380412 public ProgressTest ()
381413 {
382414 this .DeleteMode = eDeleteMode .OnLeavingForm ;
415+ Opened += ProgressTest_Opened ;
383416 }
384417
385- public override async Task Opened ( )
418+ private async Task ProgressTest_Opened ( object sender , EventArgs e )
386419 {
387420 await this .Device .Send (" Welcome to ProgressTest" );
388421 }
@@ -862,6 +895,7 @@ var bot = BotBaseBuilder
862895 })
863896 .UseSimpleJSON (AppContext .BaseDirectory + " config\\ states.json" )
864897 .UseEnglish ()
898+ .UseSingleThread ()
865899 .Build ();
866900
867901await bot .Start ();
@@ -885,6 +919,7 @@ var bot = BotBaseBuilder
885919 })
886920 .UseJSON (AppContext .BaseDirectory + " config\\ states.json" )
887921 .UseEnglish ()
922+ .UseSingleThread ()
888923 .Build ();
889924
890925await bot .Start ();
@@ -907,6 +942,7 @@ var bot = BotBaseBuilder
907942 })
908943 .UseXML (AppContext .BaseDirectory + " config\\ states.xml" )
909944 .UseEnglish ()
945+ .UseSingleThread ()
910946 .Build ();
911947
912948await bot .Start ();
0 commit comments