running next line of code after the process is completed

Sher Shah

New member
Feb 6, 2020
Programming Experience
Hello !!
i am new to coding and i am writing code in visual studio using c#.
I run a process there (basically double clicking a file which internally runs and give us output as text file).
In next line i wrote a code for getting that text file created as a result of process.
The problem is process running and giving text file as output take some seconds and mean while the next file which is getting text file says null. Because creation of text file need some seconds. Is there any method i can put a break or something so that when is completed then next line of code should run.

Here is my code lines:

List<string> lines = File.ReadAllLines(@"D:\My.txt").ToList();
This should help:
Waiting for several seconds should not be done in UI thread, if your app has that, then use a secondary thread to start and wait for the process.
Last edited:
Top Bottom