Solved

Open two files as process

Posted on 2011-02-25
6
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

626 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