|
YmFzZSA2NCBpcyB0aGUgc2hpem5pdCE=
but wasteful when you want to load just binary data.
Note the above base 64 string, was originally a 23 char string (thus 23bytes) that would be saved in XML as a 32 char string (32 bytes) plus the over head of decoding
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
Isn't that what I was saying?
|
|
|
|
|
Yep, just adding to your post with an example for him to follow
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
I have a small C# command line app that uses a COM server component written by a 3rd party. The COM server triggers exposes events which I can subscribe to using delegates. However my function callbacks are invoked in a different thread than the main thread. Is there a way to "post" back to the main thread? I don't have a GUI, and the sample program that came with the component uses a GUI and the Control.BeginInvoke methods to post back to the main thread. Is there an alternate way to do this? I'm using .Net 1.1, I could migrate to 2.0, but that's as "high" as I can go.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Jim Crafton wrote: I don't have a GUI
Then you do not need it.
|
|
|
|
|
Thanks, I'll be breathlessly waiting for you to tell me the color of the sky later on
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
enum ColorOfSky
{
Blue,
Gray,
Black
}
Really HTH
|
|
|
|
|
I am not sure I understand what you are getting at.
AFAIK, all Control.Invoke does, it the execute the delegate on the control's thread, and this is done by queuing the delegate in the control's message loop.
|
|
|
|
|
You're right got Control.Invoke - that's sort of the equivalent of SendMessage, a blocking call. But Control.BeginInvoke is kind of like PostMessage, it posts the delegate callback to the control's thread that it belongs too (usually the main UI thread), and the callback gets executed in the that threads context.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
So this means you make an async call to this 3rd party control? What mechanism do you use to keep the main thread from exiting?
My COM is a little rusty but can't you force an Apartment model on the control?
led mike
|
|
|
|
|
Actually other way around (sort of). The 3rd party triggers "events" via COM's Connection Point mechanism. .Net nicely wraps this up using delegates. However, due to the way the 3rd party control is written, these delegates are getting fired in a different thread than the main one, and it appears that I need be in the main thread to make calls on the 3rd part COM object.
So what I'm would like is a way to "post" a call back to the main thread. One way I had thought of was using an AutoResetEvent and making up my own "event" queue, but this seems like a lot of silly work to do something that I would expect the framework to support out of the box. There must be something I'm missing.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Nothing wrong with using an event as long as the design of your main thread allows it to be blocked. That's why I asked how you are keeping the main thread from exiting.
led mike
|
|
|
|
|
Oops, sorry, something like this:
while ( server.Running )
{
server.checkForClients();
System.Windows.Forms.Application.DoEvents();
}
I think this is OK to do (it certainly seems to work OK).
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Jim Crafton wrote: I think this is OK to do
Depends how you define "OK". polling is certainly not best practice.
However adding your current problem to that design you could just use a synchronized queue or stack or something and another call to check it
while ( server.Running )
{
server.checkForClients();
server.checkForCOMServerMessages();
System.Windows.Forms.Application.DoEvents();
} You probably don't want to mix the two, and possibly can't. So like this:
#1 convert polling design to notification design and add notification from COM Server created thread
#2 add another polling mechanism to include messages from COM Server created thread
led mike
|
|
|
|
|
led mike wrote: Depends how you define "OK". polling is certainly not best practice.
True.
I've given up on the command line version. I just made a simple UI that minimizes to the system tray. This gives me a form I can use BeginInvoke on and things seem to be working better now. Still awfully silly.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
I am serializing a class that has an array of type Base.
The type of each of these items is actually a subclass of Base (many different types).
To avoid requiring the Base class to know about all the subclasses, using [XmlInclude] (since this isn't an option for me since some of the subclasses are dynamically compiled and not known at compilation time), when I create the serializer, I pass an array of types like so:
XmlSerializer serial = new XmlSerializer( typeOfObjectToBeSerialized, extraTypesArray );
That works great. I can then use the same serializer to deserialize the file. Wonderful. . . .
Except . . . in practice, I'm not deserializing immediately after serializing. I wrote it out to a file because I want to save the state and be able to shut down the program, come back later and deserialize it. At that point, I no longer have that extraTypesArray, and it can't deserialize without it.
Does anybody have a clever solution to this problem? The only thing I can think to do add a load of strings to the beginning of the xml file and pull them out at the beginning, turn them into types somehow, and use them to create the serializer. But I'm hoping for something cleaner. Any ideas?
|
|
|
|
|
Eric Burns wrote: But I'm hoping for something cleaner. Any ideas?
Nope, that's XmlSerialization for you.
Just as tip, you only need to include one type per assembly. Example, I needed something in System.dll, so I simply added an enum type as the extra types, and it worked. Maybe this will work for you as well.
|
|
|
|
|
Hi,
I writing some windows Form application in and when the user is minimize the Main form i want to show some notification icon near the windows clock.
How can i do it ?
|
|
|
|
|
Yanshof,
MSDN?[^]
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
How about actually giving an answer for once, and not just a link to MSDN? Post a little about the page you are linking to.
|
|
|
|
|
Thanks for the help -
That was what i looking for - but how can i remove the application from the task bar and see the application only as Troy icon ?
I did as same as was in the example - and i see that the application in the troy and in the task bar also ...
Thanks for the help
|
|
|
|
|
There is a property on the form called ShowInTaskbar... set it to false.
|
|
|
|
|
i want to convert this code to c#.
Dim btn As Button = CType(sender, Button)
i tried with
btn as button;
Convert.changetype(sender,button);
but it gives an error saying that button is a type and used as a variable
|
|
|
|
|
Button btn = (Button)sender;
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: Button btn = (Button)sender;
And one like (if (sender.GetType().Name == "Button") ) would make it generic and exception-resistant. I am actually trying to see how to avoid the System.InvalidCastException The specified cast is not valid .
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
All the world's a stage,
And all the men and women merely players.
They have their exits and their entrances;
And one man in his time plays many parts... --William Shakespeare
|
|
|
|