To answer your first question, use .Contains to check for spaces:
bthHash3.Enabled = !myString.Contains(" ");
Since you are just setting a boolean, I collapsed the if into one line. To answer your second, it slightly depends on if you are in a multi-threaded environment. Of course, you could always write the following:
ReadMyFile(file1);
ReadMyFile(file2);
myButton.Enabled = true;
Which works since ReadMyFile should block while reading, so the enabled line won't be hit until all the reads are complete. If you are threaded, then do this:
int completeCount = 0;
void ThreadedRead()
{
//Read file synchronously
completedCount++;
CheckReadCompletion();
}
void CheckReadCompletion()
{
if (completedCount == 2)
myButton.Enabled = true;
}
You would start "ThreadedRead" for each file you need to read. Please let me know if I can clarify anything!
You wouldn't need to do this in the above scenario (because you are just setting the enabled flag) but with complex enough behavior, make sure to put a lock around completedCount
and the call to CheckReadCompletion. You could modify it to this:
int completeCount = 0;
object completionLock = new object();
void ThreadedRead()
{
//Read file synchronously
lock (completionLock)
{
completedCount++;
CheckReadCompletion();
}
}
void CheckReadCompletion()
{
if (completedCount == 2)
myButton.Enabled = true;
}