I was surprised that convenient System.Threading.Timer class does not exist in Profile 78 libraries. To use this class I created another PCL which targets 4.0 framework and wrote a simple wrapper around (as it was suggested in one blog post):
public class PCLTimer
{
private Timer timer;
private Action<object> action;
public PCLTimer (Action<object> action, object state, int dueTimeMilliseconds, int periodMilliseconds)
{
this.action = action;
timer = new Timer (PCLTimerCallback, state, dueTimeMilliseconds, periodMilliseconds);
}
private void PCLTimerCallback (object state)
{
action.Invoke (state);
}
public bool Change (int dueTimeMilliseconds, int periodMilliseconds)
{
return timer.Change (dueTimeMilliseconds, periodMilliseconds);
}
}
Now I can reference this 4.0 library and use PCLTimer in main PCL library. But when I try to build my main Android project I get following warnings:
Warning CS1684: Reference to type 'System.Threading.Timer' claims it is defined in 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile78\mscorlib.dll', but it could not be found (CS1684) (Prototype.Core)
Warning MSB3247: Found conflicts between different versions of the same dependent assembly. (MSB3247) (Prototype.Droid)
How to get rid of these warnings properly?