mirror of
https://github.com/mgroves/MonodroidStockPortfolio.git
synced 2025-01-01 03:00:17 +00:00
23 lines
662 B
C#
23 lines
662 B
C#
|
using Android.App;
|
||
|
using Android.Util;
|
||
|
using PostSharp.Aspects;
|
||
|
|
||
|
namespace MonoStockPortfolio.Framework
|
||
|
{
|
||
|
public class OnGuiThreadAttribute : MethodInterceptionAspect
|
||
|
{
|
||
|
public override void OnInvoke(MethodInterceptionArgs args)
|
||
|
{
|
||
|
var activity = args.Instance as Activity;
|
||
|
if (activity == null)
|
||
|
{
|
||
|
Log.Error("OnGuiThreadAttribute", "OnGuiThreadAttribute can only be used on methods within an Activity");
|
||
|
args.Proceed();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
activity.RunOnUiThread(args.Proceed);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|