Skip to content

Commit

Permalink
Fixed some threading issues on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Nezz authored and tomspilman committed Feb 25, 2013
1 parent dde0c18 commit 51da9a7
Showing 1 changed file with 35 additions and 25 deletions.
60 changes: 35 additions & 25 deletions MonoGame.Framework/iOS/GamerServices/SignedInGamer.cs
Expand Up @@ -298,15 +298,19 @@ public void AwardAchievement( string achievementId )

public void DoAwardAchievement( string achievementId, double percentageComplete )
{
GKAchievement a = new GKAchievement(achievementId);
a.PercentComplete = percentageComplete;
a.ReportAchievement( delegate(NSError error){
if (error != null)
{
// Retain the achievement object and try again later (not shown).
}

} );
UIApplication.SharedApplication.InvokeOnMainThread(delegate
{
GKAchievement a = new GKAchievement(achievementId);
a.PercentComplete = percentageComplete;
a.ReportAchievement(delegate(NSError error)
{
if (error != null)
{
// Retain the achievement object and try again later (not shown).
}

});
});
}

public void AwardAchievement( string achievementId, double percentageComplete )
Expand All @@ -321,29 +325,35 @@ public void UpdateScore( string aCategory, long aScore )
{
if (IsSignedInToLive)
{
GKScore score = new GKScore(aCategory);
score.Value = aScore;
score.ReportScore(delegate (NSError error)
{
if (error != null)
{
// Oh oh something went wrong.
}
});
UIApplication.SharedApplication.InvokeOnMainThread(delegate
{
GKScore score = new GKScore(aCategory);
score.Value = aScore;
score.ReportScore(delegate(NSError error)
{
if (error != null)
{
// Oh oh something went wrong.
}
});
});
}
}

public void ResetAchievements()
{
if (IsSignedInToLive)
{
GKAchievement.ResetAchivements(delegate (NSError error)
{
if (error != null)
{
// Oh oh something went wrong.
}
});
UIApplication.SharedApplication.InvokeOnMainThread(delegate
{
GKAchievement.ResetAchivements(delegate(NSError error)
{
if (error != null)
{
// Oh oh something went wrong.
}
});
});
}
}

Expand Down

0 comments on commit 51da9a7

Please sign in to comment.