In The Hand LtdIn The Hand
TryStart Method (suppressPermissionPrompt, timeout)
NamespacesInTheHand.Device.LocationGeoCoordinateWatcherTryStart(Boolean, TimeSpan)
.NET Components for Mobility
Initiates the acquisition of data from the current location provider. This method returns synchronously.
Declaration Syntax
C#Visual Basic
public bool TryStart(
	bool suppressPermissionPrompt,
	TimeSpan timeout
)
Public Function TryStart ( _
	suppressPermissionPrompt As Boolean, _
	timeout As TimeSpan _
) As Boolean
Parameters
suppressPermissionPrompt (Boolean)
Not used.
timeout (TimeSpan)
Time in milliseconds to wait for the location provider to start before timing out.
Return Value
true if data acquisition is started within the time period specified by timeout; otherwise, false.
Remarks
This method blocks during the time period specified by timeout. Use caution when calling TryStart from the user interface thread of your application.
Examples
The following example demonstrates how to call TryStart.
CopyC#
using System;
using System.Device.Location;

namespace GetLocationProperty
{
    class Program
    {
        static void Main(string[] args)
        {
            GetLocationProperty();
        }

        static void GetLocationProperty()
        {
            GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();

            // Do not suppress prompt, and wait 1000 milliseconds to start.
            watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));

            GeoCoordinate coord = watcher.Position.Location;

            if (coord.IsUnknown != true)
            {
                Debug.WriteLine("Lat: {0}, Long: {1}", coord.Latitude, coord.Longitude);
            }
            else
            {
                Debug.WriteLine("Unknown latitude and longitude.");
            }
        }
    }
}

Assembly: InTheHand.Device (Module: InTheHand.Device) Version: 7.0.0.0