|
In the System.Net.NetworkInformation namespace, there is a Ping object, that can ping either an IP address, or a host-name (the name of the computer). Use the Ping.Send( string ) or Ping.Send( IPAddress ) methods and get a PingReply object with details about the host or address pinged.
See How to ping a hostname/ip using ASP.NET 2.0 and C# .NET[^] for an example of using the Ping and PingReply objects.
|
|
|
|
|
I use conditional compilation symbols to enable and disable client cusomised parts of my code.
Is there a built-in way to determine at run time what symbols were defined at build time?
|
|
|
|
|
Take five minutes and think again about your question, I think you already gave yourself the answer
The answer is "No". The IL does not contain any references to the code not compiled by the preprocessor directives.
Code like this:
#if DEBUG
Console.WriteLine("Debug");
#else
Console.WriteLine("Release");
#endif
will lead to following IL code:
L_0000: nop
L_0001: ldstr "Debug"
L_0006: call void [mscorlib]System.Console::WriteLine(string)
L_000b: nop
if compiled in debug mode, otherwise "Release".
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Sure, I realised I could engineer code to produce exactly that, but I wondered if it might have been built-in. Perhaps in the assembly meta data, and reflection would be able to find it. But I guess not.
thanks anyway
|
|
|
|
|
Certainly not automatically, but if it's important enough you could probably engineer a mechanism.
Something along these lines comes to mind:
public static readonly System.Collections.Generic.HashSet<string> DefinedOptions =
new System.Collections.Generic.HashSet<string>() ;
...
# if DEBUG
DefinedOptions.Add ( "DEBUG" ) ;
...
# endif
But that would only work where such statements are valid.
On the other hand, I question whether or not using conditional compilation is an appropriate technique for your requirement.
|
|
|
|
|
Hi all,
I am trying to create a custom toolstrip control, that will allow me to put in some toolstripbuttons that should display each time I make use of this control in a form. This way I don't have to recreate the toolstip over and over again.
So first question, is this the right way of doing it? and secondly how does one create such a control sothat when you place the control on your form, the toolstripbuttons actual display?
Many thanks in advance
Kind regards,
The only programmers that are better those C# programmers are those who code in 1's and 0's |
Programm3r
My Blog: ^_^
|
|
|
|
|
Sounds reasonable. Derive a class from ToolStrip, and in the constructor add your buttons to it. You can then just use this interchangably with a normal ToolStrip on your forms.
Regards,
Rob Philpott.
|
|
|
|
|
|
Simple, this will add a ToolStripLabel label1 by default.
using System.Windows.Forms;
namespace MyControls
{
public class MyToolStrip :ToolStrip
{
ToolStripLabel label1;
public MyToolStrip()
{
InitializeComponent();
}
private void InitializeComponent()
{
label1 = new ToolStripLabel();
label1.Text = "Tool Strip Label";
Items.Add(label1);
}
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
|
|
This would be better if the event were passed to the form that has the toolstrip. 2 Options:
1. Make the button public public ToolStripButton button1; then it can be accessed in the form
myToolStrip1.button1.Click += new EventHandler(button1_Click);
2. Better I think, raise your own ButtonClick event.
public event EventHandler ButtonClick;
ToolStripButton button1;
public MyToolStrip2()
{
InitializeComponent();
}
private void InitializeComponent()
{
button1 = new ToolStripButton();
button1.Click += new EventHandler(button1_Click);
button1.Text = "Open another Form";
Items.Add(button1);
}
void button1_Click(object sender, EventArgs e)
{
EventHandler eh = ButtonClick;
if (eh != null)
eh(sender, e);
} then access the ButtonClick event of your toolstrip in the normal way
myToolStrip1.ButtonClick += new EventHandler(myToolStrip1_ButtonClick);
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Thank you very much for the helpful input.
Kind regards,
The only programmers that are better those C# programmers are those who code in 1's and 0's |
Programm3r
My Blog: ^_^
|
|
|
|
|
You're welcome
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
An article that I wrote for the CodeProject might help: Custom ToolStrip Renderers[^]
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
I have developed a client/server model and the text messaging works fine. now i want to add audio conferencing to it but have no idea from where to start. can you tell me from where to start and which classes i will need. i am open for any further reading
thanks
Zain
|
|
|
|
|
There's an <b>amazing</b> web site called google that may be of use. It requires a working web-browser, but as you can access codeproject, I'm sure you can navigate there.
Failong that, in answer to your second part:
coasphantom wrote: which classes i will need
MacDonalds do all the training on site, there's no need for extra classes.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Do you mean McDonalds? (I used 'Google' for correct spelling) - and they dont do all training on site
|
|
|
|
|
I was thinking of the other lot...
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
How much training do you need to say "Do you want fries with that?"
|
|
|
|
|
You would not get trained to say that at all.
Suggestive selling in the event of a single burger, for example, being ordered would be something along the lines of 'Would you like to make that a meal?'
at least in the UK anyway
P.S to say the line you quoted would actually take a fair bit of training, but thats what school is for :P
|
|
|
|
|
I suspect they have changed what they say precisely because everyone jokes about the old 'do you want fries with that' line.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
It was always "sell up once" in my day:
Customer: Big Mac n fries
Dunce: Is that a large fries?
Customer: Just gimme the fokin mac'n'fries yer motha!
- or -
Customer: Big Mac, fries ana coke
Dunce: Is that a large coke?
Customer: If I wanna large coke I'l ask fer a large coke! Get me ma food! C___!
I miss it, really I do.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Spot on their mate.
As you have described - some customers just dont have the intelligence to handle placing a simple food order
|
|
|
|
|
Speaks a man of experience (20+ years ago, but experience non the less)
The guys on the tills, known as dunces in the trade, are generally the day1 dudes who haven't yet learnt how to press the button on the frier.
After that they move onto be a junior fry guy, or Muckfit. By this point they have been through the first six week training program which entails pouring frozen chips into a basket, placing basket in frier and pressing the button. The senior fry guy is allowed to take them out when the beeper goes beep and deposit them in the fry bin.
A few months will have past before they are elevated to the back of the store to prepare the buns for the burgers. This rather senior position goes by the name Bap Stacker. You don't want to know what the front of house call him.
A year or so down the line, you may get to actualling putting the burgers on the grill. This is not easy as it may seem. From memory they have to press the button THREE times during the process; highly stressful.
I did this to get a bit of extra cash when I was at Uni. When I left to get a real job, the store manager offered me a perminent position and was perplexed that I wanted to work 9-5 in an office without smelling of grease. Actually, I think he just said "Duh?". To this day I cannot stand McD's and I think it's close to 15 years since I last went into one.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|