last day (17 days later) » 

3:00 PM
0
A: How to Run specific part of codes in Program Main just once in C#?

Steve DrakeSingle app example bool createdNew; Mutex m = new Mutex(true, "YOURAPPNAME", out createdNew); if (!createdNew) { MessageBox.Show("already running!"); return; }

 
ACE
Thanks Steve But I know how to do make application single instance only But problem is : MessageBox.Show("already running!"); runs n times (n= Selected Files in explorer) how to force it run just once?
 
the return will make it quit, the MessageBox is just for illustration.
This code goes BEFORE you open your form.
 
ACE
Steve Assume you run make 10 shortcuts from this application then run all of them Result will be Showing messageBox 10 times! I that messageBox showed just 1 time!
 
The message box is not meant for production code, its to show what its doing, remove it :)
Do you need to PASS the file to the RUNNING app? that's more complex, but can be done.
 
ACE
your previous comment: I know it's just for showing but it means that that part run n times! for last comment: yeah I think that's what I'm looking for But when i use args it just show me path of 1 file! Not all selected file
Hi Steve
Are you there?
 
3:04 PM
hello
 
ACE
first thanks for your help
 
when it runs once, what do the args contain?
do they look like an array of all the files?
 
ACE
args.length= 1 (2 items)
args[1] will be filepath
let me check it again
ok yeah just 1 item in args
I said wrong first args[1] is null!
 
is it related to how you have register the file association, do you need to say it supports more than one file??
I have used click once in the past, not sure if that will do what you need as its more limited
 
ACE
I think yes that's exactly what I should I think it would be related to registry I think I should add a value that collects all selected file not each file 1 by 1
 
3:13 PM
if you remove your single instance code, and just make it debug out the file, that will make it easyer to test. eg, create a SPIKE
I use this
 
ACE
Thanks i will check it now
do you use Windows Media Player?
or Winamp or JetAudio?
 
I have in the past.
I think they use DDE, or they used to. That's me realy showing my age
You can tell windows to fire a DDE message to an application if its already open, or you used to be able to
 
ACE
how old are you?
my exact goal is what those player do
how to do that?
what is DDE message?
sorry I'm amateur
 
DDE is probs deprecated
I would try click once
 
ACE
what about this: https://msdn.microsoft.com/en-us/library/windows/desktop/hh127436%28v=vs.85%29.aspx
I think may this could solve what i'm looking for
ARE those "DDE" and "Click once" are different from each other?
Can you please give me some sample?
 
3:19 PM
DDE is very old, like 20 years old
I used it in Windows 3.1
Click once is something you pick on the props of the project in visual studio
it creates a special setup program
 
ACE
WoW! you are a real experienced Programmer
 
I have been around for some time :)
 
ACE
:)
can you please any reference link or sample that could help me do those solutions you are talking about?
I stuck in this part about two weeks :(
I used many things but all of them has some kind of problem!
and my worth problem is no one understand my question! :(
How should I ask it properly? why People just come and votedown for no reason!?
hey I think accidentally I found something that could be what I'm looking for
take a look at this please: https://msdn.microsoft.com/en-us/library/windows/desktop/dd940369%28v=vs.85%29.aspx#requirements
 
that might help
I would look at how media player works
do it have one program as the PLAYER
and another program that just adds things to a LIST
and starts the PLAYER if its not running
 
ACE
what makes me surprised was that many other players does not work properly such as VLCplayer,MPCstar & many other players they have problems too!
Just WMP&Winamp&JetAudio Works Properly
 
3:33 PM
have a look at hanselman.com/blog/…
 
ACE
I'm reading it, tnx
How can I contact you again? can I?
facebook? line ID,etc.?
 
I am very busy, Stack is good
 
ACE
:( thanks, are you usually online? for example next 5-6 hours? or tomorrow?
 
having a BBQ in about an hour :)
 
ACE
barbeque?
 
3:41 PM
yep, nice and warm in the UK
well, warm for the uk :)
 
ACE
:D :)
we have a statement" نوش جان" it is useful for you now! I don't what would it be in English
 
Bon Appetit
I used google translate

'bon appetit / enjoy your meal'
thanks, I need to get back to my day job :)
good luck
 
ACE
yeah enjoy your meal, that's what i meant :)
Good Luck too ;)
I will test what you said and what i found myself and inform you if it solved
 

  last day (17 days later) »