0

I'm working on cross platform .net standard 2.0 library (targeting Windows, iOS, Android).

There is some operation that I need to perform only once on the local machine.

If (!MethodAExecuted)
{
    MethodA();
    MethodAExecuted = true;
}

What I can do to achieve such behaviour in cross platform way?

InfernumDeus
  • 1,185
  • 1
  • 11
  • 33
  • Depends on how often this method is called and how long the "this method was called" info needs to be available. (dict in singleton service, SQL server, redis, … just no name a few options) – Christoph Lütjen Jul 23 '18 at 15:56

1 Answers1

1

The only thing I could think of would be to have a web service end-point where instead of:

MethodAExecuted = true

you could call the web service to set the status and another to determine if the status had ever been set. That would be completely platform independent since it would be based on open standards. The implementation on each platform would only have to honor the contract in the web service's WSDL.

Note: how you handle things like timing, concurrency, etc. is up to you. But since the call to the web service is platform independent, you can tailor that on a per-platform basis.