-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It no longer supports datetime checking.
add JobHandler.cs
- Loading branch information
1 parent
7d2a5ca
commit 7805a3e
Showing
4 changed files
with
76 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using eXtensionSharp.Job; | ||
using NUnit.Framework; | ||
|
||
namespace eXtensionSharp.test; | ||
|
||
public class JobProcessorTest | ||
{ | ||
[Test] | ||
public async Task job_processor_test() | ||
{ | ||
JobProcessor<string>.Instance.SetProcessor(JobHandler<string>.Instance, item => | ||
{ | ||
if(item.xIsNotEmpty()) TestContext.WriteLine(item); | ||
}); | ||
JobProcessor<int>.Instance.SetProcessor(JobHandler<int>.Instance, item => | ||
{ | ||
if(item > 0) TestContext.WriteLine(item); | ||
}); | ||
|
||
var texts = "hello world"; | ||
var numbers = new[] { 1, 2, 3, 4, 5 }; | ||
|
||
Parallel.ForEach(texts.ToArray(), item => | ||
{ | ||
JobHandler<string>.Instance.Enqueue(item.ToString()); | ||
}); | ||
Parallel.ForEach(numbers, item => | ||
{ | ||
JobHandler<int>.Instance.Enqueue(item); | ||
}); | ||
|
||
await Task.Delay(5000); | ||
|
||
JobProcessor<int>.Instance.Stop(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters