Pull and Push problem

  • Thread starter Thread starter Flying Whiz
  • Start date Start date
F

Flying Whiz

I have a Download button on my start up form where I allow user to
download data and Upload button on another form where he can upload
his data to the server.But these two events can be done when the
Pocket PC is in the craddle.But when the user accidently or mistakenly
tap these buttons when the pocket PC is not in the craddle then my
application is going into a loop..An hour glass comes into picture and
I need to do a hard reset on the device to get out of that.How can I
show him a message when the user does this action.


Whiz
 
I can't remember the person that posted this on the
newsgroup...but here' a piece of code that I found useful.
public enum CradleResult : uint{Cradled, Uncradled,
WebException, OtherException};
const string Home = "127.0.0.1";
public CradleResult IsDeviceCradled()
{
try
{
string HostName = Dns.GetHostName();
System.Net.IPHostEntry IPHost = Dns.GetHostByName
(HostName);
string DeviceIP = IPHost.AddressList[0].ToString();
if(DeviceIP != IPAddress.Parse(Home).ToString())
{
return Network.CradleResult.Cradled;
}
else { return Network.CradleResult.Uncradled;}
}
catch(System.Net.WebException webEx)
{
return Network.CradleResult.WebException;
}
catch(System.Exception othEx)
{
return Network.CradleResult.OtherException;
}
}
 
If Dns.GetHostByName("PPP_PEER") does not throw an exception, then your
device is cradled
 
Back
Top