|
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
|
|
|
|
|
Vasudevan Deepak Kumar,
One word. YUK!
Button btn = sender as Button;
If (btn == null)
return;
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Gareth H wrote: One word. YUK!
I'll second that.
I actually felt nauseas for a second or two.
Semicolons: The number one seller of ostomy bags world wide. - dan neely
|
|
|
|
|
what about:
if ( sender is Button )
{
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
prasadbuddhika wrote: Dim btn As Button = CType(sender, Button)
Try this:
Button btn = sender as Button;
if (btn != null)
{
} Basically, if you cast an object using Button btn = (Button)sender; you end up with an exception if sender isn't a button (or child of said type). The "as" keyword, attempts the cast and leaves it as null if can't complete the cast - hence the null test. There is a third option, but it's a bit wasteful:
Button btn = null;
if (sender is Button)
btn = (Button)sender;
|
|
|
|
|
Hi all,
In my project, i wish to send a remaider email to the users at regular intervals.
please help me with a sample code.
thanks
Fakeer
"FAKEER"
|
|
|
|
|
Just put your email send in a timer event.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
you'll need to use % operator
|
|
|
|
|
fakeer4uever,
What is a at "regular intervals"?
Every minute? or every 3 days?, or even longer...
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
You may need to use a Windows Service to achieve this.
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
|
|
|
|
|
Here's some sample code:
while (true)
{
SendRemaiderEmail();
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
I'm transmitting recorded video file over LAN using UDP but sometimes file transmit successfully and sometimes at receiving side(client) it doesn't receive properly whereas at server side I get transmitting message.
Please See my code and give me suggestion to overcome this problem.
public void filercvold()<br />
{ <br />
<br />
outStream = File.OpenWrite(filepath);<br />
bufOutStream = new BufferedStream(outStream);<br />
<br />
i=0;<br />
while (i<=fsize)
{<br />
try<br />
{<br />
<br />
<br />
idsock.ReceiveFrom(rcvfilebuf, ref idep);<br />
<br />
bufOutStream.Write(rcvfilebuf, 0, rcvfilebuf.Length);<br />
<br />
i++;<br />
<br />
}<br />
catch (SocketException ttt)<br />
{<br />
MessageBox.Show(ttt.Message);<br />
}<br />
<br />
}<br />
<br />
bufOutStream.Flush();<br />
bufOutStream.Close(); <br />
outStream.Close(); <br />
MessageBox.Show("File is completly received!!");<br />
}
//outStream is FileStream Object
//bufOutStream is BufferedStream Object
idsock is socket object
// rcvfilebuf = new byte[16384]; 16KB packet
Now whenever I got last msg "File is completly received" File fully saved and run properly. but when I dont get this msg as at server side I got transmitting msg but at same time at client side above notification doesn't show as client become stuck or remain in this statement " ReceiveFrom(rcvfilebuf, ref idep);"
Now tell me how to check this or rcv full video every time as it doesnt happen everytime.By same code I got this msg and run video file at client but by same code above problem I face so what is main reason or where I'm doing wrong.
Thanx in advance.
Regards,
Shanzay
|
|
|
|
|
Without seeing all of the related code, we probably can't help you.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi All,
According to my requirement i need to get the webpagepreview of the active word document in a new window. Can anyone help with this...
This is my code
protected Microsoft.Office.Interop.Word.ApplicationClass objWord = new ApplicationClass();
object fltDocFormat = 10;
protected object missing = System.Reflection.Missing.Value;
protected object readOnly = false;
protected object isVisible = false;
object FileName //The path where i stored the file
objWord.Documents.Open(ref FileName, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing, ref missing);
Microsoft.Office.Interop.Word.Document oDoc = objWord.ActiveDocument;
oDoc.WebPagePreview();
objWord.Quit(ref missing, ref missing, ref missing);
The preview is coming in the same window i need it in a new browser window
Plz help
|
|
|
|