-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from Suriya-Balamurugan/master
Added example for multithreading
- Loading branch information
Showing
20 changed files
with
371 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...ersion/Multithreaded-using-parallel-process/.NET/Multithreaded-using-parallel-process.sln
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,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.31911.196 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Multithreaded-using-parallel-process", "Multithreaded-using-parallel-process\Multithreaded-using-parallel-process.csproj", "{C17B90BC-F559-456B-B189-90B53FF6CDD4}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {EF357FC6-E9E5-4E3C-B932-43F727BE1DE4} | ||
EndGlobalSection | ||
EndGlobal |
Binary file added
BIN
+116 KB
...threaded-using-parallel-process/.NET/Multithreaded-using-parallel-process/Data/Input.pptx
Binary file not shown.
22 changes: 22 additions & 0 deletions
22
...ess/.NET/Multithreaded-using-parallel-process/Multithreaded-using-parallel-process.csproj
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,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RootNamespace>Multithreaded_using_parallel_process</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.PresentationRenderer.Net.Core" Version="*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="Data\Input.pptx"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Output\.gitkeep"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
1 change: 1 addition & 0 deletions
1
...threaded-using-parallel-process/.NET/Multithreaded-using-parallel-process/Output/.gitkeep
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 @@ | ||
|
46 changes: 46 additions & 0 deletions
46
...Multithreaded-using-parallel-process/.NET/Multithreaded-using-parallel-process/Program.cs
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,46 @@ | ||
using Syncfusion.Presentation; | ||
using Syncfusion.Pdf; | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using Syncfusion.PresentationRenderer; | ||
|
||
namespace Multithreaded_using_parallel_process | ||
{ | ||
class MultiThreading | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
//Indicates the number of threads to be create. | ||
int limit = 5; | ||
Console.WriteLine("Parallel For Loop"); | ||
Parallel.For(0, limit, count => | ||
{ | ||
Console.WriteLine("Task {0} started", count); | ||
//Convert multiple presentations, one PPT on each thread. | ||
ConvertPowerPointToPDF(count); | ||
Console.WriteLine("Task {0} is done", count); | ||
}); | ||
} | ||
//Convert a Powerpoint presentation to PDF using multi-threading. | ||
static void ConvertPowerPointToPDF(int count) | ||
{ | ||
using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Input.pptx"), FileMode.Open, FileAccess.Read)) | ||
{ | ||
//Load an existing PowerPoint presentation. | ||
using (IPresentation presentation = Presentation.Open(inputStream)) | ||
{ | ||
//Convert PowerPoint presentation to PDF. | ||
using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(presentation)) | ||
{ | ||
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output" + count + ".pdf"), FileMode.Create, FileAccess.Write)) | ||
{ | ||
//Save the PDF document. | ||
pdfDocument.Save(outputFileStream); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
PPTX-to-PDF-conversion/Multithreaded-using-tasks/.NET/Multithreaded-using-tasks.sln
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,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.31911.196 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Multithreaded-using-tasks", "Multithreaded-using-tasks\Multithreaded-using-tasks.csproj", "{C17B90BC-F559-456B-B189-90B53FF6CDD4}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {EF357FC6-E9E5-4E3C-B932-43F727BE1DE4} | ||
EndGlobalSection | ||
EndGlobal |
Binary file added
BIN
+116 KB
...o-PDF-conversion/Multithreaded-using-tasks/.NET/Multithreaded-using-tasks/Data/Input.pptx
Binary file not shown.
22 changes: 22 additions & 0 deletions
22
...Multithreaded-using-tasks/.NET/Multithreaded-using-tasks/Multithreaded-using-tasks.csproj
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,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RootNamespace>Multithreaded_using_tasks</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.PresentationRenderer.Net.Core" Version="*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="Data\Input.pptx"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Output\.gitkeep"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
1 change: 1 addition & 0 deletions
1
...o-PDF-conversion/Multithreaded-using-tasks/.NET/Multithreaded-using-tasks/Output/.gitkeep
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 @@ | ||
|
47 changes: 47 additions & 0 deletions
47
PPTX-to-PDF-conversion/Multithreaded-using-tasks/.NET/Multithreaded-using-tasks/Program.cs
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,47 @@ | ||
using Syncfusion.Presentation; | ||
using Syncfusion.Pdf; | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using Syncfusion.PresentationRenderer; | ||
|
||
namespace Multithreaded_using_tasks | ||
{ | ||
class MultiThreading | ||
{ | ||
//Indicates the number of threads to be create. | ||
private const int TaskCount = 1000; | ||
public static async Task Main() | ||
{ | ||
//Create an array of tasks based on the TaskCount. | ||
Task[] tasks = new Task[TaskCount]; | ||
for (int i = 0; i < TaskCount; i++) | ||
{ | ||
tasks[i] = Task.Run(() => ConvertPowerPointToPDF()); | ||
} | ||
//Ensure all tasks complete by waiting on each task. | ||
await Task.WhenAll(tasks); | ||
} | ||
|
||
//Convert a Powerpoint presentation to PDF using multi-threading. | ||
static void ConvertPowerPointToPDF() | ||
{ | ||
using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Input.pptx"), FileMode.Open, FileAccess.Read)) | ||
{ | ||
//Load an existing PowerPoint presentation. | ||
using (IPresentation presentation = Presentation.Open(inputStream)) | ||
{ | ||
//Convert PowerPoint presentation to PDF. | ||
using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(presentation)) | ||
{ | ||
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output" + Guid.NewGuid().ToString() + ".pdf"), FileMode.Create, FileAccess.Write)) | ||
{ | ||
//Save the PDF document. | ||
pdfDocument.Save(outputFileStream); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...tation/Multithreaded-using-parallel-process/.NET/Multithreaded-using-parallel-process.sln
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,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.31911.196 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Multithreaded-using-parallel-process", "Multithreaded-using-parallel-process\Multithreaded-using-parallel-process.csproj", "{C17B90BC-F559-456B-B189-90B53FF6CDD4}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {EF357FC6-E9E5-4E3C-B932-43F727BE1DE4} | ||
EndGlobalSection | ||
EndGlobal |
Binary file added
BIN
+116 KB
...threaded-using-parallel-process/.NET/Multithreaded-using-parallel-process/Data/Input.pptx
Binary file not shown.
22 changes: 22 additions & 0 deletions
22
...ess/.NET/Multithreaded-using-parallel-process/Multithreaded-using-parallel-process.csproj
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,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RootNamespace>Multithreaded_using_parallel_process</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.Presentation.Net.Core" Version="*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="Data\Input.pptx"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Output\.gitkeep"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
1 change: 1 addition & 0 deletions
1
...threaded-using-parallel-process/.NET/Multithreaded-using-parallel-process/Output/.gitkeep
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 @@ | ||
|
43 changes: 43 additions & 0 deletions
43
...Multithreaded-using-parallel-process/.NET/Multithreaded-using-parallel-process/Program.cs
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,43 @@ | ||
using Syncfusion.Presentation; | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
|
||
namespace Multithreaded_using_parallel_process | ||
{ | ||
class MultiThreading | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
//Indicates the number of threads to be create. | ||
int limit = 5; | ||
Console.WriteLine("Parallel For Loop"); | ||
Parallel.For(0, limit, count => | ||
{ | ||
Console.WriteLine("Task {0} started", count); | ||
//Create multiple presentations, one PPT on each thread. | ||
OpenAndSavePresentation(count); | ||
Console.WriteLine("Task {0} is done", count); | ||
}); | ||
} | ||
//Open and save a Powerpoint presentation using multi-threading. | ||
static void OpenAndSavePresentation(int count) | ||
{ | ||
using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Input.pptx"), FileMode.Open, FileAccess.Read)) | ||
{ | ||
//Load an existing PowerPoint presentation. | ||
using (IPresentation presentation = Presentation.Open(inputStream)) | ||
{ | ||
//Add a slide of TitleAndContent type. | ||
ISlide slide = presentation.Slides.Add(SlideLayoutType.TitleAndContent); | ||
//Save the presentation in the desired format. | ||
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output" + count + ".pptx"), FileMode.Create, FileAccess.Write)) | ||
{ | ||
presentation.Save(outputFileStream); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...save-PowerPoint-presentation/Multithreaded-using-tasks/.NET/Multithreaded-using-tasks.sln
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,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.31911.196 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Multithreaded-using-tasks", "Multithreaded-using-tasks\Multithreaded-using-tasks.csproj", "{C17B90BC-F559-456B-B189-90B53FF6CDD4}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {EF357FC6-E9E5-4E3C-B932-43F727BE1DE4} | ||
EndGlobalSection | ||
EndGlobal |
Binary file added
BIN
+116 KB
...int-presentation/Multithreaded-using-tasks/.NET/Multithreaded-using-tasks/Data/Input.pptx
Binary file not shown.
22 changes: 22 additions & 0 deletions
22
...Multithreaded-using-tasks/.NET/Multithreaded-using-tasks/Multithreaded-using-tasks.csproj
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,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RootNamespace>Multithreaded_using_tasks</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.Presentation.Net.Core" Version="*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="Data\Input.pptx"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Output\.gitkeep"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
1 change: 1 addition & 0 deletions
1
...int-presentation/Multithreaded-using-tasks/.NET/Multithreaded-using-tasks/Output/.gitkeep
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 @@ | ||
|
43 changes: 43 additions & 0 deletions
43
...werPoint-presentation/Multithreaded-using-tasks/.NET/Multithreaded-using-tasks/Program.cs
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,43 @@ | ||
using Syncfusion.Presentation; | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
|
||
namespace Multithreaded_using_tasks | ||
{ | ||
class MultiThreading | ||
{ | ||
//Indicates the number of threads to be create. | ||
private const int TaskCount = 1000; | ||
public static async Task Main() | ||
{ | ||
//Create an array of tasks based on the TaskCount. | ||
Task[] tasks = new Task[TaskCount]; | ||
for (int i = 0; i < TaskCount; i++) | ||
{ | ||
tasks[i] = Task.Run(() => OpenAndSavePresentation()); | ||
} | ||
//Ensure all tasks complete by waiting on each task. | ||
await Task.WhenAll(tasks); | ||
} | ||
|
||
//Open and save a Powerpoint presentation using multi-threading. | ||
static void OpenAndSavePresentation() | ||
{ | ||
using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Input.pptx"), FileMode.Open, FileAccess.Read)) | ||
{ | ||
//Load an existing PowerPoint presentation. | ||
using (IPresentation presentation = Presentation.Open(inputStream)) | ||
{ | ||
//Add a slide of TitleAndContent type. | ||
ISlide slide = presentation.Slides.Add(SlideLayoutType.TitleAndContent); | ||
//Save the presentation in the desired format. | ||
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output" + Guid.NewGuid().ToString() + ".pptx"), FileMode.Create, FileAccess.Write)) | ||
{ | ||
presentation.Save(outputFileStream); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |