Skip to content

Commit eeb10b7

Browse files
committed
Add background job and process support
1 parent e589622 commit eeb10b7

11 files changed

+463
-16
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Abp.BackgroundJobs;
2+
using DeploySoftware.LaunchPad.Core.BackgroundProcess;
3+
4+
namespace DeploySoftware.LaunchPad.Core.Abp.BackgroundProcess
5+
{
6+
public abstract partial class LaunchPadBackgroundJobBase<TArgs> :
7+
AsyncBackgroundJob<TArgs>, // ABP base async job
8+
IAsyncBackgroundJob<TArgs>, IBackgroundJobBase<TArgs>, IBackgroundJob<TArgs>, // ABP background job interfaces
9+
ICanBeLaunchPadBackgroundJob<TArgs> // LaunchPad background job interface
10+
{
11+
12+
protected LaunchPadBackgroundJobBase() : base()
13+
{
14+
15+
}
16+
17+
public virtual void Execute(TArgs args)
18+
{
19+
Logger.Debug(string.Format(DeploySoftware_LaunchPad_Core_Abp_Resources.Logger_Debug_BackgroundJob_Executing, ToString()));
20+
ExecuteAsync(args).Wait();
21+
Logger.Debug(string.Format(DeploySoftware_LaunchPad_Core_Abp_Resources.Logger_Debug_BackgroundJob_Executed, ToString()));
22+
}
23+
24+
}
25+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using Abp.Threading.BackgroundWorkers;
2+
using DeploySoftware.LaunchPad.Core.BackgroundProcess;
3+
4+
namespace DeploySoftware.LaunchPad.Core.Abp.BackgroundProcess
5+
{
6+
public abstract partial class LaunchPadBackgroundWorkerBase : BackgroundWorkerBase, ICanBeLaunchPadBackgroundWorker
7+
{
8+
protected LaunchPadBackgroundWorkerBase() : base()
9+
{
10+
}
11+
12+
/// <summary>
13+
/// Note to implementors: Make this method non-blocking
14+
/// <see cref="https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers"/>
15+
/// </summary>
16+
public override void Start()
17+
{
18+
Logger.Debug(string.Format(DeploySoftware_LaunchPad_Core_Abp_Resources.Logger_Debug_BackgroundWorker_Starting, ToString()));
19+
base.Start();
20+
Logger.Debug(string.Format(DeploySoftware_LaunchPad_Core_Abp_Resources.Logger_Debug_BackgroundWorker_Started, ToString()));
21+
}
22+
23+
/// <summary>
24+
/// Note to implementors: Make this method non-blocking
25+
/// <see cref="https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers"/>
26+
/// </summary>
27+
public override void Stop()
28+
{
29+
Logger.Debug(string.Format(DeploySoftware_LaunchPad_Core_Abp_Resources.Logger_Debug_BackgroundWorker_Stopping, ToString()));
30+
base.Stop();
31+
Logger.Debug(string.Format(DeploySoftware_LaunchPad_Core_Abp_Resources.Logger_Debug_BackgroundWorker_Stopped, ToString()));
32+
}
33+
34+
/// <summary>
35+
/// Note to implementors: Wait for the for the worker to finish whatever it is doing, before stopping
36+
/// <see cref="https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers"/>
37+
/// </summary>
38+
public override void WaitToStop()
39+
{
40+
Logger.Debug(string.Format(DeploySoftware_LaunchPad_Core_Abp_Resources.Logger_Debug_BackgroundWorker_WaitingToStop, ToString()));
41+
base.WaitToStop();
42+
Logger.Debug(string.Format(DeploySoftware_LaunchPad_Core_Abp_Resources.Logger_Debug_BackgroundWorker_WaitedToStop, ToString()));
43+
}
44+
45+
}
46+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using Abp.Threading.BackgroundWorkers;
2+
using Abp.Threading.Timers;
3+
using DeploySoftware.LaunchPad.Core.BackgroundProcess;
4+
5+
namespace DeploySoftware.LaunchPad.Core.Abp.BackgroundProcess
6+
{
7+
public abstract partial class LaunchPadPeriodicBackgroundWorkerBase : PeriodicBackgroundWorkerBase, ICanBeLaunchPadBackgroundWorker
8+
{
9+
protected LaunchPadPeriodicBackgroundWorkerBase(AbpTimer timer) : base(timer)
10+
{
11+
}
12+
13+
/// <summary>
14+
/// Note to implementors: Make this method non-blocking
15+
/// <see cref="https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers"/>
16+
/// </summary>
17+
public override void Start()
18+
{
19+
Logger.Debug(string.Format(DeploySoftware_LaunchPad_Core_Abp_Resources.Logger_Debug_BackgroundWorker_Starting, ToString()));
20+
base.Start();
21+
Logger.Debug(string.Format(DeploySoftware_LaunchPad_Core_Abp_Resources.Logger_Debug_BackgroundWorker_Started, ToString()));
22+
}
23+
24+
/// <summary>
25+
/// Note to implementors: Make this method non-blocking
26+
/// <see cref="https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers"/>
27+
/// </summary>
28+
public override void Stop()
29+
{
30+
Logger.Debug(string.Format(DeploySoftware_LaunchPad_Core_Abp_Resources.Logger_Debug_BackgroundWorker_Stopping, ToString()));
31+
base.Stop();
32+
Logger.Debug(string.Format(DeploySoftware_LaunchPad_Core_Abp_Resources.Logger_Debug_BackgroundWorker_Stopped, ToString()));
33+
}
34+
35+
/// <summary>
36+
/// Note to implementors: Wait for the for the worker to finish whatever it is doing, before stopping
37+
/// <see cref="https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers"/>
38+
/// </summary>
39+
public override void WaitToStop()
40+
{
41+
Logger.Debug(string.Format(DeploySoftware_LaunchPad_Core_Abp_Resources.Logger_Debug_BackgroundWorker_WaitingToStop, ToString()));
42+
base.WaitToStop();
43+
Logger.Debug(string.Format(DeploySoftware_LaunchPad_Core_Abp_Resources.Logger_Debug_BackgroundWorker_WaitedToStop, ToString()));
44+
}
45+
46+
}
47+
}

src/DeploySoftware.LaunchPad.Core.Abp/DeploySoftware.LaunchPad.Core.Abp.Resources.Designer.cs

Lines changed: 135 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)