-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
54 lines (45 loc) · 1.67 KB
/
Program.cs
File metadata and controls
54 lines (45 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.IO;
using System.Threading;
using net.windward.api.csharp;
namespace SemaphoreSample
{
/// <summary>
/// Sample application to show how to limits calls to Fluent to the license thread limit.
/// </summary>
public class Program
{
/// <summary>
/// Run the example.
/// </summary>
/// <param name="args">Run the example.</param>
public static void Main(string[] args)
{
// Initialize the engine
Report.Init();
string path = Path.GetFullPath("..\\..\\files");
string template = Path.GetFullPath(Path.Combine(path, "Fluent Trucking 2 - Template.docx"));
string xmlData = Path.GetFullPath(Path.Combine(path, "Fluent Trucking 2 - Data.xml"));
// put reports in out directory
string pathReports = Path.GetFullPath("..\\..\\out");
if (! Directory.Exists(pathReports))
Directory.CreateDirectory(pathReports);
// set up the reports I want to run
GenerateDocument [] myReports = new GenerateDocument[10];
for (int ind = 0; ind < myReports.Length; ind++)
myReports[ind] = new GenerateDocument(template, xmlData, Path.Combine(pathReports, string.Format("Report_{0}.docx", ind)));
// create a thread for each request
Thread[] myThreads = new Thread[myReports.Length];
for (int ind = 0; ind < myReports.Length; ind++ )
myThreads[ind] = new Thread(myReports[ind].RunReport);
// start the threads
foreach (Thread threadOn in myThreads)
threadOn.Start();
// wait for them to end
foreach (Thread threadOn in myThreads)
threadOn.Join();
Console.Out.WriteLine("all threads completed");
System.Diagnostics.Process.Start(pathReports);
}
}
}