0

I'm trying to install a series of executable files from a directory on a button press - I have it working for a single process, however I'm trying to figure out how to start another process after the previous one has finished installing.

I've tried literally just having them listed one after the other...

Process.Start(@"\\filepath\DXSDK_Feb10.exe", "/U /NoRestart");
Process.Start(@"\\filepath\DXSDK_Jun10.exe", "/U /NoRestart");

But this hasn't worked... obviously, hence why I'm searching for help :P

How can I install a list of executable files one after the other in C#?

EDIT - should've noted that I'm using Unity Engine and I don't believe that

Process.WaitForExit();

works on it

SammyJ
  • 25
  • 6

1 Answers1

-3
await Task.Run(() => Process.Start(@"\\filepath\DXSDK_Feb10.exe", "/U /NoRestart"));
Process.Start(@"\\filepath\DXSDK_Jun10.exe", "/U /NoRestart");

The task object is asynchronous, you can pass the Process.Start as a lambda expression into the Task.Run(). This will wrap the lambda expression in a task which you can then await in your main thread.

CuriousOne
  • 45
  • 6
  • You've explained what your code snippet is supposed to do, but can you explain why, and what the difference is between your answer and OP's code snippet? – CEH Nov 14 '19 at 17:29
  • It is two lines of code, the difference between this and the OP's code snippet is obvious, and I didn't think it needed to be explained. But I will edit my answer for you. – CuriousOne Nov 14 '19 at 17:34