C# 取消视频转换
我开发了一个PowerPoint加载项,可以将当前打开的演示文稿转换为.wmv文件 一切都很好。转换演示文稿时,我可以在PowerPoint底部看到一个进度条以及一个红色的X,按下该按钮可以取消转换过程 有没有一种方法可以通过编程方式调用这个取消按钮 这是我用来调用它并等待它完成的代码,但我也希望能够在它进行时取消它C# 取消视频转换,c#,visual-studio,vsto,powerpoint,C#,Visual Studio,Vsto,Powerpoint,我开发了一个PowerPoint加载项,可以将当前打开的演示文稿转换为.wmv文件 一切都很好。转换演示文稿时,我可以在PowerPoint底部看到一个进度条以及一个红色的X,按下该按钮可以取消转换过程 有没有一种方法可以通过编程方式调用这个取消按钮 这是我用来调用它并等待它完成的代码,但我也希望能够在它进行时取消它 private void frmUpload_Load(object sender, EventArgs e) { try {
private void frmUpload_Load(object sender, EventArgs e)
{
try
{
progressBarUpload.Value = 0;
string exportName = "video_of_presentation";
string exportPath = @"C:\Windows\Temp\{0}.wmv";
// Export the currently open presentation
Microsoft.Office.Interop.PowerPoint.Application ppApplication = null;
ppApplication = new Microsoft.Office.Interop.PowerPoint.Application();
ppApplication.Activate();
ppApplication.ActivePresentation.SaveAs(String.Format(exportPath, exportName), Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsWMV);
lblUploadStatus.Text = "Status: Converting …";
new Thread(() =>
{
Thread.CurrentThread.IsBackground = true;
/* run your code here */
do
{
System.Threading.Thread.Sleep(500);
}
while (ppApplication.ActivePresentation.CreateVideoStatus != Microsoft.Office.Interop.PowerPoint.PpMediaTaskStatus.ppMediaTaskStatusDone);
backgroundWorker.RunWorkerAsync();
SetControlPropertyValue(lblUploadStatus, "text", "Status: Uploading …");
}).Start();
}
catch
{
lblUploadStatus.Text = "Status: Error Converting File.";
}
}
任何帮助都将不胜感激
Trev根据MSFT,这是不可能的:( 线程在这里: 特雷夫