Solved

Open two files as process

Posted on 2011-02-25
6
235 Views
Last Modified: 2012-05-11
How to open 2 files at same time as process?  Do I need 2 process?

0
Comment
Question by:ToneElec
  • 3
  • 3
6 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34984071
What kind of files?
0
 
LVL 3

Expert Comment

by:sergiobg57
ID: 34985492
Open two files as process?

At the same time is impossible, even with 2 processes.
What you can do is use 2 threads for that purpose but it will still not be at the same time.

using System.Diagnostics;
System.Diagnostics.Process.Start("cmd");

Open in new window

//use your filename instead of cmd
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 125 total points
ID: 34985558
>>  At the same time is impossible, even with 2 processes.

Really? Then what does this code do?
using (StreamReader reader1 = new StreamReader("file1.txt"))
{
    using (StreamReader reader2 = new StreamReader("file2.txt"))
    {
        // is this not two files open at the same time  ; )
    }
}

Open in new window

0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 3

Assisted Solution

by:sergiobg57
sergiobg57 earned 125 total points
ID: 34985580
No, they are being opened consecutively.
One after another.

The way the microprocessor works for parallelism, makes this task impossible.
It's constantly scheduling threads.
One run for sometime, then it's scheduled and another one starts to run for the same amount of time.

That's how it's done.
StreamReader will just open so fast that you might not realize the difference but the difference is still there and if he has any needs to open those files really at the same time, then he will get frustrated.


But i was wrong about 2 processes.
In multi-processor systems it is possible but not likely to happen. =/
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34985612
My guess would be that the question is not about opening the files at the same exact instance of time, but I could be wrong  = )
0
 
LVL 3

Expert Comment

by:sergiobg57
ID: 34985674
That question is a bit confusing. hehe
Let's see which guess is right.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question