Permalink
Browse files

Merge pull request #1335 from Nezz/ios_threading

Fixed some threading issues on iOS
  • Loading branch information...
2 parents 62a1522 + 08eb088 commit 16d9bbf188898d7edd5b7985a1ee6c9d121d1aef @tomspilman tomspilman committed Feb 12, 2013
Showing with 35 additions and 25 deletions.
  1. +35 −25 MonoGame.Framework/iOS/GamerServices/SignedInGamer.cs
@@ -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 )
@@ -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.
+ }
+ });
+ });
}
}

0 comments on commit 16d9bbf

Please sign in to comment.