Skip to content

Commit

Permalink
Merge pull request #3 from Falven/master
Browse files Browse the repository at this point in the history
Fixed a race condition where the MainPage code-behind would attempt t…
  • Loading branch information
Ku6opr authored Dec 18, 2016
2 parents ca7d7d8 + ea4a889 commit a931222
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
10 changes: 9 additions & 1 deletion windows/Countly/Countly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ public static class Countly
// Exceptions queue
private static List<ExceptionEvent> Exceptions { get; set; }

// Raised when the async session is established
public static event EventHandler SessionStarted;

// User details info
public static CountlyUserDetails UserDetails { get; set; }

Expand Down Expand Up @@ -176,7 +179,12 @@ public static async Task StartSession(string serverUrl, string appKey, Applicati
Timer.Tick += UpdateSession;
Timer.Start();

AddSessionEvent(new BeginSession(AppKey, Device.DeviceId, sdkVersion, new Metrics(Device.OS, Device.OSVersion, Device.DeviceName, Device.Resolution, Device.Carrier, Device.AppVersion)));
await AddSessionEvent(new BeginSession(AppKey, Device.DeviceId, sdkVersion, new Metrics(Device.OS, Device.OSVersion, Device.DeviceName, Device.Resolution, Device.Carrier, Device.AppVersion)));

if (null != SessionStarted)
{
SessionStarted(null, EventArgs.Empty);
}
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion windows/CountlySample/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private void Activated()
Countly.IsLoggingEnabled = true;
Countly.IsExceptionsLoggingEnabled = true;

string ServerUrl = "http://cloud.count.ly";
string ServerUrl = "http://try.count.ly";
string AppKey = null;

if (ServerUrl == null)
Expand Down
5 changes: 3 additions & 2 deletions windows/CountlySample/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public MainPage()
{
initialized = true;

UserNameText.Text = Countly.UserDetails.Name ?? String.Empty;
Countly.SessionStarted += async (sender, args) =>
UserNameText.Text = Countly.UserDetails.Name ?? String.Empty;
};
}

Expand Down Expand Up @@ -88,7 +89,7 @@ private async void TrackingCheck_Checked(object sender, Windows.UI.Xaml.RoutedEv
{
if (initialized)
{
string ServerUrl = "http://cloud.count.ly";
string ServerUrl = "http://try.count.ly";
string AppKey = null;

if (ServerUrl == null)
Expand Down

0 comments on commit a931222

Please sign in to comment.