Link to home
Start Free TrialLog in
Avatar of Johny Bravo
Johny Bravo

asked on

Multi session in .net

I am developing a windows application in VS 2008.
In my MDIForm I have two tabs as multi-session and switch.
After logging-in,user will be able to see the MDIForm,if he clicks the Multi-session tab and then click 'Switch',it needs to open a new instance of the application.
I mean two forms running at same time.And it shud be two instances only.Means maximum two forms can be viewed at a time.

How can I do this?
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

you can use the mdiform.MDIChildren collection to check if the form already exists.
Avatar of Johny Bravo
Johny Bravo

ASKER

hi thanks for ur comment,
i will give it a try n let u know.I need 2 days for it.
Hi CodeCruiser,
Can u pls tell me how to do this?
I want two instances of the Application.
It means two MDIForms will be running.
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am getting error
proclist ia a variable but it is used as a method

I have converted it to c#
 Process[] procList = Process.GetProcesses();
            int i = 0;
            int AppCount = 0;
            for (i = 0; i <= 20 - 1; i += i + 1)
            {
                if (procList(i).ProcessName == "applicationname")
                {
                    AppCount += 1;
                }
            }
            if (AppCount < 2)
            {
            }
            else
            {
                //Start New Instance
            }
            //Already two instances running
ohh ok it's my mistake
it should be square brackets.
procList[i].ProcessName
Need your assistance
I am writing above code in Switch click event.
Following are my questions:
1>Why the loop we iterate 19 times.
2>What code should go under MultiSession click
3>What is 'applicationname",is it the solution's name?
Hi,

1) Its an oversight on my part. It should run to processlist.count - 1. Also change your loop from i += i + 1 to i++
2) All this code should go under multisession click.
3) You need to experiment with this one. I think it would be the exe name but not sure. Use a messagebox to get the name.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks CodeCruiser!!!
It works fine.
Thanks again
Can you pls tell me how can I switch between the forms?
Glad to be helpful. To switch between the forms, you could use the Form.Activate method.
Ok thanks