Click here to Skip to main content
15,911,890 members
Home / Discussions / C#
   

C#

 
GeneralRe: Looking for a good book to learn C# Pin
Brian_TheLion19-Mar-19 20:44
Brian_TheLion19-Mar-19 20:44 
GeneralRe: Looking for a good book to learn C# Pin
OriginalGriff19-Mar-19 21:17
mveOriginalGriff19-Mar-19 21:17 
AnswerRe: Looking for a good book to learn C# Pin
Ralf Meier18-Mar-19 22:28
mveRalf Meier18-Mar-19 22:28 
GeneralRe: Looking for a good book to learn C# Pin
OriginalGriff18-Mar-19 22:35
mveOriginalGriff18-Mar-19 22:35 
GeneralRe: Looking for a good book to learn C# Pin
Ralf Meier19-Mar-19 1:07
mveRalf Meier19-Mar-19 1:07 
GeneralRe: Looking for a good book to learn C# Pin
Brian_TheLion19-Mar-19 20:44
Brian_TheLion19-Mar-19 20:44 
GeneralRe: Looking for a good book to learn C# Pin
OriginalGriff19-Mar-19 21:12
mveOriginalGriff19-Mar-19 21:12 
AnswerRe: Looking for a good book to learn C# Pin
Richard MacCutchan18-Mar-19 22:45
mveRichard MacCutchan18-Mar-19 22:45 
GeneralRe: Looking for a good book to learn C# Pin
Brian_TheLion19-Mar-19 11:36
Brian_TheLion19-Mar-19 11:36 
GeneralRe: Looking for a good book to learn C# Pin
Richard MacCutchan19-Mar-19 22:54
mveRichard MacCutchan19-Mar-19 22:54 
AnswerRe: Looking for a good book to learn C# Pin
Gerry Schmitz19-Mar-19 5:46
mveGerry Schmitz19-Mar-19 5:46 
GeneralRe: Looking for a good book to learn C# Pin
Brian_TheLion19-Mar-19 12:54
Brian_TheLion19-Mar-19 12:54 
Questionc# Pin
Member 1418483718-Mar-19 17:50
Member 1418483718-Mar-19 17:50 
AnswerRe: c# Pin
OriginalGriff18-Mar-19 21:07
mveOriginalGriff18-Mar-19 21:07 
AnswerRe: c# Pin
Gerry Schmitz19-Mar-19 5:44
mveGerry Schmitz19-Mar-19 5:44 
Question(SOLVED) - How do I execute stored proc with pivot query? Pin
samflex18-Mar-19 4:39
samflex18-Mar-19 4:39 
AnswerRe: How do I execute stored proc with pivot query? Pin
Gerry Schmitz18-Mar-19 6:01
mveGerry Schmitz18-Mar-19 6:01 
GeneralRe: How do I execute stored proc with pivot query? Pin
samflex18-Mar-19 7:02
samflex18-Mar-19 7:02 
GeneralRe: How do I execute stored proc with pivot query? Pin
Gerry Schmitz18-Mar-19 9:56
mveGerry Schmitz18-Mar-19 9:56 
AnswerRe: How do I execute stored proc with pivot query? Pin
Richard Deeming18-Mar-19 9:23
mveRichard Deeming18-Mar-19 9:23 
GeneralRe: How do I execute stored proc with pivot query? Pin
samflex18-Mar-19 10:05
samflex18-Mar-19 10:05 
QuestionChecking internet connection at startup Pin
RedPandinus17-Mar-19 11:54
RedPandinus17-Mar-19 11:54 
AnswerRe: Checking internet connection at startup Pin
Luc Pattyn17-Mar-19 15:00
sitebuilderLuc Pattyn17-Mar-19 15:00 
Hi,

I have used two different ways in the past:

1. use P/Invoke to call a native Windows function with this definitions and prototype

[Flags]
enum LP_InternetConnectionState : int {
    /// <summary>Local system has a valid connection to the Internet, but it might
    /// or might not be currently connected.</summary>
    Configured=0x40,
    /// <summary>Local system uses a local area network to connect to the Internet.</summary>
    LAN=0x02,
    /// <summary>Local system uses a modem to connect to the Internet.</summary>
    Modem=0x01,
    /// <summary>Local system is in offline mode.</summary>
    OffLine=0x20,
    /// <summary>Local system uses a proxy server to connect to the Internet.</summary>
    Proxy=0x04,
    /// <summary>Local system has RAS installed.</summary>
    RAS_installed=0x10
}


    [DllImport("wininet.dll")]
    static extern bool InternetGetConnectedStateEx(ref LP_InternetConnectionState lpdwFlags,
        StringBuilder name, int nameLength, int dwReserved);


2. use the Ping class to check some site can be reached, say google.com; the relevant code looks somewhat like this (there are variants for async operation, and overloads that allow for PingOptions including time-out):

Ping ping=new Ping();
byte[] bytes=new byte[32];
IPAddress address=GetIpFromHost(host);
PingReply reply = ping.Send(address, timeout, bytes);
ipStatus=(int)reply.Status;

The advantage of 2 over 1 is it really uses internet; the disadvantage here is it takes a while when the target site can't be reached.



You may want to use Google to find out more about the functions/methods/classes mentioned.

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum


modified 17-Mar-19 21:07pm.

QuestionA Question on a C# command Pin
Brian_TheLion16-Mar-19 13:40
Brian_TheLion16-Mar-19 13:40 
AnswerRe: A Question on a C# command Pin
Dave Kreskowiak16-Mar-19 14:15
mveDave Kreskowiak16-Mar-19 14:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.