更新README
This commit is contained in:
29
README.md
29
README.md
@@ -270,6 +270,8 @@ BackgroundJob.ContinueJobWith(jobid, () => Console.WriteLine("Continuations"));
|
|||||||
|
|
||||||
### Progressing text console and show bar
|
### Progressing text console and show bar
|
||||||
|
|
||||||
|
使用 IPerformContextAccessor 從 Hangfire 的 PerformContext 取得進度管理的元件後,透過 Console 提供的擴充輸出到 GUI 管理介面。
|
||||||
|
|
||||||
```
|
```
|
||||||
NUGET INSTALL Bonura.Hangfire.PerformContextAccessor -Version 1.3.3
|
NUGET INSTALL Bonura.Hangfire.PerformContextAccessor -Version 1.3.3
|
||||||
|
|
||||||
@@ -277,3 +279,30 @@ NUGET INSTALL Hangfire.Console -Version 1.4.3
|
|||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
Console 套件同時也提供格式化輸出字串的功能。
|
||||||
|
|
||||||
|
```
|
||||||
|
// 取得 Hangfire 的進程管理
|
||||||
|
var bar = context.WriteProgressBar();
|
||||||
|
|
||||||
|
context.WriteLine("The text color change to red");
|
||||||
|
|
||||||
|
context.SetTextColor(ConsoleTextColor.Red);
|
||||||
|
|
||||||
|
context.WriteLine("This progress is ready to start");
|
||||||
|
|
||||||
|
context.ResetTextColor();
|
||||||
|
|
||||||
|
// 使用 WithProgress 方法回報進程管理,任務的進度已更新
|
||||||
|
foreach (var i in Enumerable.Range(0, seconds).ToList().WithProgress(bar))
|
||||||
|
{
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
context.SetTextColor(ConsoleTextColor.Green);
|
||||||
|
|
||||||
|
context.WriteLine("This progress has finished");
|
||||||
|
|
||||||
|
context.ResetTextColor();
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user