|
|
Thank you for the link but when I click it I get a 404 resource not found. Has the page moved?
David
|
|
|
|
|
|
OK got a problem here with our firewall and proxy server. Once I connected to s different network I can get to the links. The WMI example is interesting, I 'll give it a try. I do like the idea of letting an event tell me what was created and deleted, should give me a better idea of what is going on. Thanks again for all you help.
David
|
|
|
|
|
Glad to help you
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Okay, so I've been trying to find an answer to this for a while and either I'm not looking in the right place or it's not out there. I figured I'd post here while I continue my search to see if anyone has encountered this. I'm writing a WCF service that needs to accept a System.Exception parameter. I have this done and it's working, problem is that all other exceptions that derive from System.Exception (e.g. ArgumentException) are not recognized, since System.Exception is a System class and not one I created I can't very well decorate it with the KnownType attribute, at least I don't think I can. Does anyone know how I can accept all exception types as a parameter?
- Arcond
|
|
|
|
|
Is it better to load images from xml file or from the folders. Currently I save just the path in xml and load from the image director created on windows. Thanks
|
|
|
|
|
I would imagine that if you load an image from a file that is just the image then that would be faster than extracting a base64 representation out of an XML file then converting it to binary before you can consider processing it.
|
|
|
|
|
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.
|
|
|
|