From: Peter Duniho on
Mr. Arnold wrote:
> Bill wrote:
>> Hello
>>
>> I've got a C# console app, that calls a startup function in a C# dll
>> that I have created. In my DLL, as I'm processing data, I want to
>> display some logging information, but I want to pass it back to the
>> console app, and have it write the text to the console as it comes
>> from the DLL, but I'm not sure how I should do this....
>
> You're easiest option would be to make a public object with get/set for
> string value and pass the object between the console app and the dll.
> You would instantiate the object in the console app and send it (by ref)
> to the dll.
>
> You come out of the dll back to the console app and print what's in the
> object's string property.

Assuming the use scenario is exactly as above (object is simply a
container for a string object), how is that better than simply returning
a string object from a method? Or passing a string variable
by-reference (i.e. with "out")?

I take the original question as wanting something more dynamic. That
is, not just a simple transactional "DLL does X, client code than gets
string it prints", but rather a more general mechanism by which the DLL
can arbitrarily send strings back to the client code.

But if the OP is looking for a transactional approach, wrapping a string
in an object when a simple method return value or by-reference argument
would do seems like overkill to me.

Pete
From: Bill on
I just setup a delegate in my DLL, then in my calling console app, I create
an instance of the delgete, and pass that into the constructor of the class
in the DLL, and assign it to a this.del where del is of delegate type.

In my console application I've got a function that prints out the strings.

Not sure if it is the best way to go, but it works

"Peter Duniho" <NpOeStPeAdM(a)NnOwSlPiAnMk.com> wrote in message
news:0ZqdnTvGlcftcbHRnZ2dnUVZ_vqdnZ2d(a)posted.palinacquisition...
> Mr. Arnold wrote:
>> Bill wrote:
>>> Hello
>>>
>>> I've got a C# console app, that calls a startup function in a C# dll
>>> that I have created. In my DLL, as I'm processing data, I want to
>>> display some logging information, but I want to pass it back to the
>>> console app, and have it write the text to the console as it comes from
>>> the DLL, but I'm not sure how I should do this....
>>
>> You're easiest option would be to make a public object with get/set for
>> string value and pass the object between the console app and the dll. You
>> would instantiate the object in the console app and send it (by ref) to
>> the dll.
>>
>> You come out of the dll back to the console app and print what's in the
>> object's string property.
>
> Assuming the use scenario is exactly as above (object is simply a
> container for a string object), how is that better than simply returning a
> string object from a method? Or passing a string variable by-reference
> (i.e. with "out")?
>
> I take the original question as wanting something more dynamic. That is,
> not just a simple transactional "DLL does X, client code than gets string
> it prints", but rather a more general mechanism by which the DLL can
> arbitrarily send strings back to the client code.
>
> But if the OP is looking for a transactional approach, wrapping a string
> in an object when a simple method return value or by-reference argument
> would do seems like overkill to me.
>
> Pete


From: Peter Duniho on
Bill wrote:
> I just setup a delegate in my DLL, then in my calling console app, I create
> an instance of the delgete, and pass that into the constructor of the class
> in the DLL, and assign it to a this.del where del is of delegate type.
>
> In my console application I've got a function that prints out the strings.
>
> Not sure if it is the best way to go, but it works

If you expect the common use case to be the client code calling
Console.WriteLine(), then the approach I suggested is simpler and more
appropriate.

But a callback mechanism is fine too, and may be more appropriate if a)
your DLL always is returning individual strings, one at a time, without
regard to console formatting, and b) you expect to have to use this
implementation outside the context of the Console class on a regular basis.

Pete
From: Mr. Arnold on
Bill wrote:
> I just setup a delegate in my DLL, then in my calling console app, I create
> an instance of the delgete, and pass that into the constructor of the class
> in the DLL, and assign it to a this.del where del is of delegate type.
>
> In my console application I've got a function that prints out the strings.
>
> Not sure if it is the best way to go, but it works
>
> "Peter Duniho" <NpOeStPeAdM(a)NnOwSlPiAnMk.com> wrote in message
> news:0ZqdnTvGlcftcbHRnZ2dnUVZ_vqdnZ2d(a)posted.palinacquisition...
>> Mr. Arnold wrote:
>>> Bill wrote:
>>>> Hello
>>>>
>>>> I've got a C# console app, that calls a startup function in a C# dll
>>>> that I have created. In my DLL, as I'm processing data, I want to
>>>> display some logging information, but I want to pass it back to the
>>>> console app, and have it write the text to the console as it comes from
>>>> the DLL, but I'm not sure how I should do this....
>>> You're easiest option would be to make a public object with get/set for
>>> string value and pass the object between the console app and the dll. You
>>> would instantiate the object in the console app and send it (by ref) to
>>> the dll.
>>>
>>> You come out of the dll back to the console app and print what's in the
>>> object's string property.
>> Assuming the use scenario is exactly as above (object is simply a
>> container for a string object), how is that better than simply returning a
>> string object from a method? Or passing a string variable by-reference
>> (i.e. with "out")?

What -- you think it's about something being better? All I provided was
a simple solution no more or no less.


I don't need you in my face about it.
From: "Mr. Arnold" MR. on

"Bill" <someplace(a)somewhere.com> wrote in message
news:Op5z59VGLHA.1996(a)TK2MSFTNGP06.phx.gbl...
>I just setup a delegate in my DLL, then in my calling console app, I create
>an instance of the delgete, and pass that into the constructor of the class
>in the DLL, and assign it to a this.del where del is of delegate type.
>
> In my console application I've got a function that prints out the strings.
>
> Not sure if it is the best way to go, but it works


Oh, my post was not directed it at you. I can't see the other person. I
don't know why I can't see his posts nor do I care, and that's using two
readers.