473,395 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Stand alone Executable return argument

Hi,
I have a very serious issue at hand. I have created a small C# Console App
(Csd.exe) that collects a list of files as its argument and generates their
Md5 sets.
This application is used by other applications in my dept, which simply call
this Csd.exe app and passing a list of files.
I want to ask how can I return a value from this Csd.exe application as an
indicator or a signal to the calling app that Csd.exe has finished working.
The problem is that the main component of my Csd.exe is a

public static void main(string[] args)
{
//All the work
//And that is it (done)!
//Here i want to enter a return int or a bool (true) so that the caller
can know
//that i am finished processing....
}

The Static void main does not let me return anything. How can i do that.

Please HELP!

Thanks and Regards
Sunny

Nov 16 '05 #1
6 8818
Sunny,

You really aren't going to be able to pass a value back through the
executable. The best you could do is pass an integer back to the process
that triggered you.

If possible, you should refactor this code out into a component, and
integrate that component into the other applications that need it. It would
be easy enough to expose this as a .NET and a COM component, which should
allow you to access it from almost anywhere.

If you need to keep this as an executable, then you might want to
consider having it write out files to another directory, which you can
relate to the original files, which have the MD5 hash in them, or store the
hashes in some other persistant format (like a database) where the other
applications can get to it.

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

"Sunny" <Su***@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
Hi,
I have a very serious issue at hand. I have created a small C# Console App
(Csd.exe) that collects a list of files as its argument and generates
their
Md5 sets.
This application is used by other applications in my dept, which simply
call
this Csd.exe app and passing a list of files.
I want to ask how can I return a value from this Csd.exe application as an
indicator or a signal to the calling app that Csd.exe has finished
working.
The problem is that the main component of my Csd.exe is a

public static void main(string[] args)
{
//All the work
//And that is it (done)!
//Here i want to enter a return int or a bool (true) so that the caller
can know
//that i am finished processing....
}

The Static void main does not let me return anything. How can i do that.

Please HELP!

Thanks and Regards
Sunny

Nov 16 '05 #2
I appreciate all the help, I am in fact writing out a set of Xml files at
this time as my work process and at the end of the process i am infact
invoking a third application that in turns (indirectly) signals to my caller
as a signal of my work completion. However this app is being used almost by
all the other apps and i have been told to return a signal to the caller that
i have finished my work in addition to the files written out, since they
don't always want to go and read the files as such.

But I think there has got to be a way for the. static void main(string[]
args) to return some signal values to their callers, this simply defies all
logic that this is not prossible in this scenario...
would look forward to any more suggestions. . .

Thanks for the Help,

With Regards
Sunny

"Nicholas Paldino [.NET/C# MVP]" wrote:
Sunny,

You really aren't going to be able to pass a value back through the
executable. The best you could do is pass an integer back to the process
that triggered you.

If possible, you should refactor this code out into a component, and
integrate that component into the other applications that need it. It would
be easy enough to expose this as a .NET and a COM component, which should
allow you to access it from almost anywhere.

If you need to keep this as an executable, then you might want to
consider having it write out files to another directory, which you can
relate to the original files, which have the MD5 hash in them, or store the
hashes in some other persistant format (like a database) where the other
applications can get to it.

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

"Sunny" <Su***@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
Hi,
I have a very serious issue at hand. I have created a small C# Console App
(Csd.exe) that collects a list of files as its argument and generates
their
Md5 sets.
This application is used by other applications in my dept, which simply
call
this Csd.exe app and passing a list of files.
I want to ask how can I return a value from this Csd.exe application as an
indicator or a signal to the calling app that Csd.exe has finished
working.
The problem is that the main component of my Csd.exe is a

public static void main(string[] args)
{
//All the work
//And that is it (done)!
//Here i want to enter a return int or a bool (true) so that the caller
can know
//that i am finished processing....
}

The Static void main does not let me return anything. How can i do that.

Please HELP!

Thanks and Regards
Sunny


Nov 16 '05 #3
Just change public static void main to public static int main, and return
whever error code you want to return to the process. Then any other process
running your EXE can check the return code.

--Bob

"Sunny" <Su***@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
Hi,
I have a very serious issue at hand. I have created a small C# Console App
(Csd.exe) that collects a list of files as its argument and generates
their
Md5 sets.
This application is used by other applications in my dept, which simply
call
this Csd.exe app and passing a list of files.
I want to ask how can I return a value from this Csd.exe application as an
indicator or a signal to the calling app that Csd.exe has finished
working.
The problem is that the main component of my Csd.exe is a

public static void main(string[] args)
{
//All the work
//And that is it (done)!
//Here i want to enter a return int or a bool (true) so that the caller
can know
//that i am finished processing....
}

The Static void main does not let me return anything. How can i do that.

Please HELP!

Thanks and Regards
Sunny

Nov 16 '05 #4
Hi Nicholas great to see you finally after a long time.
Thanks for the info, infact i am writing out an xml file as my work process
and at the end my app is invoking a third application that signals to my
caller as a signal of my work completion, but this app is being used by a lot
of apps in my dept and there is a req now that it must return a signal value
so that the caller does not always have to go and check something else to
find out if i have finished.
I was thinking there would be a better way to return a status signal to the
callers even in a static void main implementations

public static void main(string[] args)
{
//All the work
myInternalClass mc = new myInternalClass(args);
//Now finished and return something
}

Thanks for all the help, and welcome for more suggestions. ..

With Regards
Sunny

"Nicholas Paldino [.NET/C# MVP]" wrote:
Sunny,

You really aren't going to be able to pass a value back through the
executable. The best you could do is pass an integer back to the process
that triggered you.

If possible, you should refactor this code out into a component, and
integrate that component into the other applications that need it. It would
be easy enough to expose this as a .NET and a COM component, which should
allow you to access it from almost anywhere.

If you need to keep this as an executable, then you might want to
consider having it write out files to another directory, which you can
relate to the original files, which have the MD5 hash in them, or store the
hashes in some other persistant format (like a database) where the other
applications can get to it.

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

"Sunny" <Su***@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
Hi,
I have a very serious issue at hand. I have created a small C# Console App
(Csd.exe) that collects a list of files as its argument and generates
their
Md5 sets.
This application is used by other applications in my dept, which simply
call
this Csd.exe app and passing a list of files.
I want to ask how can I return a value from this Csd.exe application as an
indicator or a signal to the calling app that Csd.exe has finished
working.
The problem is that the main component of my Csd.exe is a

public static void main(string[] args)
{
//All the work
//And that is it (done)!
//Here i want to enter a return int or a bool (true) so that the caller
can know
//that i am finished processing....
}

The Static void main does not let me return anything. How can i do that.

Please HELP!

Thanks and Regards
Sunny


Nov 16 '05 #5
Sunny,

You could do a number of things, but you won't be able to get a return
value back through the parameters, or through the return value. The entry
point for the application can only return an integer (which does not meet
your needs) and it can not modify the command line arguments. Any signal
that you send (perhaps an event, not the kind in .NET, but the
synchronization object) would have to be something that the other programs
actively listen for.

Because of these needs, it really is a better idea if you place it in a
component and have the clients or something else call the component. This
way, you can be more sure when the method completes, (instead of waiting for
an event, you just wait until the method call completes).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Sunny" <Su***@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.com...
I appreciate all the help, I am in fact writing out a set of Xml files at
this time as my work process and at the end of the process i am infact
invoking a third application that in turns (indirectly) signals to my
caller
as a signal of my work completion. However this app is being used almost
by
all the other apps and i have been told to return a signal to the caller
that
i have finished my work in addition to the files written out, since they
don't always want to go and read the files as such.

But I think there has got to be a way for the. static void main(string[]
args) to return some signal values to their callers, this simply defies
all
logic that this is not prossible in this scenario...
would look forward to any more suggestions. . .

Thanks for the Help,

With Regards
Sunny

"Nicholas Paldino [.NET/C# MVP]" wrote:
Sunny,

You really aren't going to be able to pass a value back through the
executable. The best you could do is pass an integer back to the process
that triggered you.

If possible, you should refactor this code out into a component, and
integrate that component into the other applications that need it. It
would
be easy enough to expose this as a .NET and a COM component, which should
allow you to access it from almost anywhere.

If you need to keep this as an executable, then you might want to
consider having it write out files to another directory, which you can
relate to the original files, which have the MD5 hash in them, or store
the
hashes in some other persistant format (like a database) where the other
applications can get to it.

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

"Sunny" <Su***@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
> Hi,
> I have a very serious issue at hand. I have created a small C# Console
> App
> (Csd.exe) that collects a list of files as its argument and generates
> their
> Md5 sets.
> This application is used by other applications in my dept, which simply
> call
> this Csd.exe app and passing a list of files.
> I want to ask how can I return a value from this Csd.exe application as
> an
> indicator or a signal to the calling app that Csd.exe has finished
> working.
> The problem is that the main component of my Csd.exe is a
>
> public static void main(string[] args)
> {
> //All the work
> //And that is it (done)!
> //Here i want to enter a return int or a bool (true) so that the
> caller
> can know
> //that i am finished processing....
> }
>
> The Static void main does not let me return anything. How can i do
> that.
>
> Please HELP!
>
> Thanks and Regards
> Sunny
>


Nov 16 '05 #6
Hi Sunny,
The Static void main does not let me return anything. How can i do that.


Main method can return an integer. The caller can check the return value
using its prcess handler or in realm of .NET using object of the Process
class.

If you only want to signal when the *exe* finish you have options. Look at
the Process class
You are going to use that class either to start the *exe* or to attach to
already running one.

Then your options are:
1. To block the caller until the other process finishes -
Process.WaitForExit and then if you need to check Process.ExitCode, which is
whatever integer the *exe*'s main method returns
2. To check periodically Porcess.HasExited and if it has to get the ExitCode
3. To hook on Exited event. It will be fired as soon as the process exits.
And then again you can check its ExitCode.

Even thought the process may exited long time ago its ExitCode will stay
valid until you dispose the process object (or close the process handle in
terms of Win32 API).

You can dispose the process by call its Dispose or you can leave this to the
the GC.

If you need to communicate big chunk of data, though, what you can do is
either to use files, or redirect the standart input and output. I believe
that using sockets or .NET remoting isn't worth it. Actually, do you have
some options here as well.

--
HTH
Stoitcho Goutsev (100) [C# MVP]

Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tom | last post by:
Hi folks, (note: Newbie post) I have inherited the code maintenance and development of an existing internal webservice written in c#. It's a fairly standard client, appserver, dbserver...
121
by: David Pendrey | last post by:
I was wondering if it is at all posible to write a stand alone .EXE program in Visual Studio .NET. Hopefully in VB.NET but if not another language would be ok. Thanks for the assistance
16
by: Roman Yankin | last post by:
Hello All, Is there a way to compile C# windows application as a stand alone program? In my univ class we don't have VS.NET installed and I need to have my executable running with out .NET...
13
by: Brett | last post by:
Ok, we all know a stand alone .NET EXE isn't possible, unless you want to shell out $4k (see previous post with similar subject). Frankly, I don't. Given that, what are the options for VB...
7
by: Ulrich Wisser | last post by:
Hi, I would like to stop the postmaster every night and run vacuum pg_dump reindex in the stand alone backend.
2
by: jim-on-linux | last post by:
py help, The file below will run as a stand alone file. It works fine as it is. But, when I call it from another module it locks my computer, The off switch is the only salvation. This...
7
by: David S. Zuza | last post by:
Does anybody know if it is possible to develop stand alone vb2005 apps that require no install and could be run from a flash drive or cd? If so I am trying to figure it out. thanx in advance.
1
by: samfori | last post by:
i'm just new and i want to know how to build a stand alone program (executable)from scripts of C++ code i.e. from .h and .cpp files
2
by: Zehra Ali | last post by:
I was wondering if anyone knew how one could go about developing a stand alone executable version of a web based application written in Java . Currently we are using Net beans platform. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.