c#停止程序将事件发送到事件查看器

时间:2016-07-07 12:01:30

标签: c#

我做了一个简单的程序,当你点击一个按钮时,访问你的gps坐标。这也通过向我不想要的事件查看器发送消息来警告用户。我做了研究,并尝试以下列方式进行,但它不适合我。

    string Longitude;
    string Latitude;

    [ServiceProcessDescriptionAttribute("SBAutoLog")]

    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        AutoLog = false; //disables sending events to the event viewer
    }

    private void button1_Click(object sender, EventArgs e) //gets users gps
    {
        GeoCoordinateWatcher GEOWatcher = new GeoCoordinateWatcher();
        System.Threading.Thread.Sleep(750);
        GEOWatcher.TryStart(false, TimeSpan.FromMilliseconds(1000));
        GeoCoordinate Coordinates = GEOWatcher.Position.Location;

        if (Coordinates.IsUnknown != true)
        {
            Latitude = Coordinates.Latitude.ToString();
            Longitude = Coordinates.Longitude.ToString();
            GEOWatcher.Dispose();
        }
        else
        {
            GEOWatcher.Dispose();
        }
    }

    public static bool AutoLog { get; set; }

感谢任何帮助,谢谢

0 个答案:

没有答案