|
Of course, your connection has to be stable. I pinged some random servers, and with 30000 or so pings, the lowest and highest are less than 20 ms apart.
And if the program is a little smart, it will notice when the ping changes (upstream in other PC on LAN), so it will adjust the timeout settings.
I believe nothing like this is made so far, and I think it might work real well.
The program mainly avoids package loss on otherwise stable connections.
Thanks for you feedback, let's hope some more CPers will give their opinion.
|
|
|
|
|
While drawing in a double buffered control, how would one get a hold of the actual Bitmap that .NET is holding for the buffering? So you could set individual pixels for example. Aside from using yet another bitmap to do all of the drawing, which is what double buffering is doing in the first place.
Thanks
|
|
|
|
|
This is a double buffering code: (Its from Beginnning C# books by wrox publisher).Maybe it helps you:
Graphics displayGraphics = e.Graphics;
Random r = new Random();
Image i = new Bitmap(ClientRectangle.Width, ClientRectangle.Height);
Graphics g = Graphics.FromImage(i);
g.FillRectangle(Brushes.White, ClientRectangle);
for (int x = 0; x < ClientRectangle.Width; x++)
{
for (int y = 0; y < ClientRectangle.Height; y += 10)
{
Color c = Color.FromArgb (r.Next(255), r.Next(255),
r.Next(255));
Pen p = new Pen(c, 1);
g.DrawLine(p, new Point(0, 0), new Point(x, y));
p.Dispose();
}
}
displayGraphics.DrawImage(i, ClientRectangle);
i.Dispose();
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
While I appreciate the answer, please read the question before answering it…
The .NET Control already has the ControlStyles.UserPaint | ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint styles set, which provides double buffering for the control.
As a mater a fact, I am already doing something like what you posted (on top of double buffering) to get to any kind of SetPixel method.
What I would like to know is if I can get a hold of the bitmap .NET already has, for the double buffering I told it to do?
Thanks
|
|
|
|
|
Neil Van Note wrote:
While I appreciate the answer, please read the question before answering it…
Ok,I'll do it.
Neil Van Note wrote:
The .NET Control already has the ControlStyles.UserPaint | ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint styles set, which provides double buffering for the control.
I didn't know this one,thanks.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
I looked through the docs and nothing obvious stuck out at me. I even tried doing some p/invoke but got nowhere.
It looks like you can't get the underlying bitmap unless you create it yourself
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
That’s what I found, I was hopping I was wrong...
So this leads be to my second question. Is there a method that I am not seeing, that will allow me to set an individual pixel, other than those of the Bitmap’s?
I am already creating a Bitmap to achieve this, I was just hopping there was a more direct method. Again, nothing in the documentation is jumping out at me.
Thanks
|
|
|
|
|
Nothing directly unfortunately, you might be able to use DrawLine to simulate it.
It really looks like GDI+ (ie the System.Drawing namespace) was meant for higher level operations.
You can make a call out to gdi32.dll with p/invoke, but that could possibly be a real performance drag. I'll come up with a sample and compare the results of p/invoke and Bitmap.SetPixel
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
>> "you might be able to use DrawLine to simulate it"
Haaa, if it comes down to that, I'll stick with the Bitmap, the performance is actually pretty good considering I am keeping it around for the life of the control.
P/Invoke can be a good and bad thing, the number of Sets are numerous and again, I would rather use the extra Bitmap, than to call out to SetPixelV 1000 times.
I would be curious to see what your performance test show.
Regards
|
|
|
|
|
I've created a benchmark program, VS.NET project and batch file provided to compile it.
GDIvsGraphics.zip
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
Interesting results, while the internal Bitmap.SetPixel is still the clear winner, The PInvoke performance is not as bad as I thought is was going to be.
Regards
|
|
|
|
|
Whats even better is that the Graphics version is slowed down a little by calling clr.ToARGB() each iteration even though it isn't used. This was done so the comparison would be in using P/Invoke instead of P/Invoke and the needed call to ToARGB().
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
True, Normally I wouldn't do such things in a benchmark; I feel benchmarks like this should only perform the work necessary to achieve the same end result, and not equivalent processing.
I massaged the code a little and ran it under DevPartner Profiler to obtain (for my actual scenario) more accurate results.
Thanks and Regards
|
|
|
|
|
What is the default encoding method of anything else instead of text files like :
EXE, Archive File (ZIP,RAR,ACE,...) and all others stuff, I tried Unicode Encoding but It;s not working.
I created a multiple file tools and everythings work fine but when I extract the files which are EXE and archives I don't have the correct encoding method because the files are corrupted or don't have the same size, but when I created the multiple files everything seems to be ok because i have one file with the same size as the sum of all the files in this file
anyone have the answer to this question ?
Thanks
|
|
|
|
|
I am not sure what you are trying to achieve, but the types of files you are talking about wouldn't have a text encoding. They are straight 8 bit with no encoding.
|
|
|
|
|
Thanks for the tips
BTW what's mean UTF-7 UTF-8 ??
is it something like UNICODE TEXT FORMATTER ?
thanks again
|
|
|
|
|
Yes. If you do a search in MSDN you will get an abundance of information.
Regards
|
|
|
|
|
I search MSDN and the error I got in my program what reliated to UTF-16 so UnicodeEncoding but it's not working anyway. I don't know why I got this error because If i test it on multiple files like TXT Files I don't have any trouble but when i'm talking about EXE and Archive i got error. That Strange !!
anyway if anybody have the answer or if you want me to send you my sample, just beep me
jonathan.pouliot@tecksys.com
ICQ : 71682311
Thanks
|
|
|
|
|
Sure, send a sample, and I will get it to work.
The statement in your original post, "I created a multiple file tools" didn't give me a lot of insight on what you are trying to achieve, sorry.
Email: vannote@netaxs.com
Regards
|
|
|
|
|
I've really tried to make sense out of the extender provider samples, but not a one of them does the same way, and none of them are relatively trivial. What I am looking for is the ability to add one simple 'boolean' to every object on my form.
Sounds simple... So what am I doing wrong?
I added on a project to my main application and created a component of out this. I can get it to show up, but in no combination of aggravation can I make the boolean property appear on the controls.
Can anyone help me out!
Thanks!!
----------------------------------------------
using System;
using System.ComponentModel;
using System.Windows.Forms;
namespace StatusMessage
{
[ProvideProperty( "StatusMessage", typeof( Object ))]
public class StatusMessaging : Component, IExtenderProvider
{
private bool bUpdateStatusBar = false;
[DefaultValue(false)]
public bool GetStatusMessage( Control pControl )
{
return bUpdateStatusBar;
}
public void SetStatusMessage( Control pControl, bool value )
{
bUpdateStatusBar = value;
}
public bool CanExtend( object pControl )
{
if( pControl is Component ) return true;
else return false;
}
}
}
|
|
|
|
|
Let me update the code. After 300 iterations, it just didn't look right
namespace StatusMessage
{
/// <summary>
/// Summary description for UserControl1.
/// </summary>
[ProvideProperty( "StatusMessage", typeof( bool ))]
public class StatusMessaging : Component, IExtenderProvider
{
/// <summary>
/// Required designer variable.
/// </summary>
protected bool bUpdateStatusBar = false;
public bool GetStatusMessage( Control pControl )
{
return bUpdateStatusBar;
}
public void SetStatusMessage( Control pControl, bool value )
{
bUpdateStatusBar = value;
}
public bool CanExtend( object pControl )
{
if( pControl is Control )
return true;
return false;
}
}
}
|
|
|
|
|
psdavis wrote:
[ProvideProperty( "StatusMessage", typeof( bool ))]
Try making it typeof(Control). You need to tell the UI what type of objects you want the property to appear for. It works out the type your property will provide from the GetStatusMessage and its return type.
I can send you an example I have that I wrote which provides a simple extender to a control. I was going to write it up as an article, but I dont haev time.
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
Suppose someone were writing a "firewall" application that was "watching" or listening for activity over an incoming IP address, what is the best way to cover all ports. In all the examples I have read, someone creates an instance of TcpListener and supplies a port to listen to. Surely you don't have to do that for each of the 65,000+ ports. Could someone lead me in the right direction. Thanks.
Nick Parker
|
|
|
|
|
There is probably some winsock/system hook buried somewhere deep in the win32 API, that tells you when there is an inbound connection request.
I looked at SetWindowsHookEx but it didn't seem to offer it, and I didn't see anything in the WinSock API. Perhaps someone more knowledgeable than me can fill you in, in the VC++ forum.
Once you find it, you can use P/Invoke to access it. Or at the most you would have to write a MC++ layer to act as the middleman for your C# code and the system.
Good Luck,
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
James T. Johnson wrote:
There is probably some winsock/system hook buried somewhere deep in the win32 API
So you think a system hook is the way to go??
This might be a great article idea, when I find more time/information I will post something, I tried the VC++ forum but only got one response that was unfortunately no help. I'll keep searching
Nick Parker
|
|
|
|