By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,630 Members | 1,166 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,630 IT Pros & Developers. It's quick & easy.

Form Instances & Networks

P: n/a
Request comments on the code that should be wriiten:

1. Need users to start a application from local network but only allow one
instance of the application to run on EACH users machine while, at the same
time, allowing multiple network users to execute application
(http://www.bobpowell.net/singleinstance.htm )?

2. Within this application are database forms (MS-Access, DataGrid, etc).
For these forms, there should be only one network instance
of the form running because multiple users saving or
changing database records may create DataSet problems, etc. ??
(http://www.yoda.arachsys.com/csharp/...ation.instance )??

Or I'm I missing something?

Steve

Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

"Steve B." <St****@discussions.microsoft.com> wrote in message
news:D8**********************************@microsof t.com...
Request comments on the code that should be wriiten:

1. Need users to start a application from local network but only allow one instance of the application to run on EACH users machine while, at the same time, allowing multiple network users to execute application
(http://www.bobpowell.net/singleinstance.htm )?
This is one way of doing it, it will work fine IF you can assure that no
other window in the system will have the same name ( title) , there are
other ways of doing this like listening to a port( I strongly dislike this )
use a named pipe, etc I thnk that you will find an answer in the faqs or in
the archives
2. Within this application are database forms (MS-Access, DataGrid, etc).
For these forms, there should be only one network instance
of the form running because multiple users saving or
changing database records may create DataSet problems, etc. ??
(http://www.yoda.arachsys.com/csharp/...ation.instance )??


if you require that more than one instance run in the lan you will have to
deal with concurrency , what db r u using? or how you are using it.
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Nov 16 '05 #2

P: n/a
Steve,

See inline:
1. Need users to start a application from local network but only allow
one
instance of the application to run on EACH users machine while, at the
same
time, allowing multiple network users to execute application
(http://www.bobpowell.net/singleinstance.htm )?
This is simple enough. In your Main method, you would do something like
this:

// Tells whether or not the Mutex was acquired.
bool acquired = false;

// Try to acquire a mutex:
using (Mutex mutex = new Mutex(true, typeof(MyForm).FullName, out acquired))
{
// If the mutex was acquired, then run the app.
if (acquired)
{
// Run the app.
Application.Run(new MyForm());
}
}

Basically, this creates a named mutex (with the full name of the type,
which will help guarantee uniqueness of the name). If the mutex was
acquired, then your app will run, otherwise, it will not.

I think the bigger issue you have here will be security. Since you are
going to run this on a network share, you will have to make sure that the
security policy on each machine is set so that it grants the appropriate
rights to the app (it will run with reduced permissions because it is run
from the network).

2. Within this application are database forms (MS-Access, DataGrid, etc).
For these forms, there should be only one network instance
of the form running because multiple users saving or
changing database records may create DataSet problems, etc. ??
(http://www.yoda.arachsys.com/csharp/...ation.instance )??
I think that the above statement is not a good thing. It basically is
implying that you are going to use locking of some kind on the record being
modified. This in general is a bad practice which severely limits
scalability. Rather, you should be looking at optimistic concurrency
techniques (like checking a timestamp, perhaps).

Hopet his helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

Or I'm I missing something?

Steve

Nov 16 '05 #3

P: n/a
Thank You very much for info

I implemented #1 and it works great [at leasted on my machine] . I'm going
to do some research on Mutex(). In regards to #2 I'm using MS-Access and VS.
I had no idea about Mutex() and optimistic concurrency techniques topics. -
again thank you. I just need to be pointed in right direction....

Yes, I'm very concerned about security too. Security is a real problem
around my neck. Right now I have to go to each user’s machine and run the
framework wizard and give the foo assembly "full trust”. In my aggravation
I've also run: caspol -enterprize -addfulltrust foo.exe, but I still seem to
have to run the wizard and give it full fulltrust.

Any advice? - Steve
"Nicholas Paldino [.NET/C# MVP]" wrote:
Steve,

See inline:
1. Need users to start a application from local network but only allow
one
instance of the application to run on EACH users machine while, at the
same
time, allowing multiple network users to execute application
(http://www.bobpowell.net/singleinstance.htm )?


This is simple enough. In your Main method, you would do something like
this:

// Tells whether or not the Mutex was acquired.
bool acquired = false;

// Try to acquire a mutex:
using (Mutex mutex = new Mutex(true, typeof(MyForm).FullName, out acquired))
{
// If the mutex was acquired, then run the app.
if (acquired)
{
// Run the app.
Application.Run(new MyForm());
}
}

Basically, this creates a named mutex (with the full name of the type,
which will help guarantee uniqueness of the name). If the mutex was
acquired, then your app will run, otherwise, it will not.

I think the bigger issue you have here will be security. Since you are
going to run this on a network share, you will have to make sure that the
security policy on each machine is set so that it grants the appropriate
rights to the app (it will run with reduced permissions because it is run
from the network).

2. Within this application are database forms (MS-Access, DataGrid, etc).
For these forms, there should be only one network instance
of the form running because multiple users saving or
changing database records may create DataSet problems, etc. ??
(http://www.yoda.arachsys.com/csharp/...ation.instance )??


I think that the above statement is not a good thing. It basically is
implying that you are going to use locking of some kind on the record being
modified. This in general is a bad practice which severely limits
scalability. Rather, you should be looking at optimistic concurrency
techniques (like checking a timestamp, perhaps).

Hopet his helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

Or I'm I missing something?

Steve


Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.