PDF Archive

Easily share your PDF documents with your contacts, on the Web and Social Networks.

Share a file Manage my documents Convert Recover PDF Search Help Contact



Appendices.pdf


Preview of PDF document appendices.pdf

Page 1 234136

Text preview


Console Applications

Basic application structure

When creating a new console project in Xamarin, the main program file will be
named Program.cs and will look as follows:
using System;
namespace Sensor
{
class MainClass
{
public static void Main (string[] args)
{
Console.WriteLine ("Hello World!");
}
}
}

Logging events

All projects in this book will use the following setup, and we describe it only here for
brevity. First, we will add the following using statements, since we will not only use
multiple threads but also the sleep function and event logging:
using System.Threading;
using Clayster.Library.EventLog;
using Clayster.Library.EventLog.EventSinks.Misc;

The event logging architecture allows for any number of event sinks to be registered.
Event sinks can be used to analyze the event flow, store events, or send events to the
network somewhere. If event logging is done properly when building applications,
it's easy at a later stage to add more advanced event logging capabilities, for instance,
sending events from things to a central repository for monitoring and analysis. For our
purposes, it is sufficient at this point to only output events to the terminal window.
For this reason, we will add the following code to the top of the Main() method:
Log.Register (new ConsoleOutEventLog (80));
Log.Information ("Initializing application...");

[2]