<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to Track Licensing for a Custom Extension in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-track-licensing-for-a-custom-extension/m-p/1205945#M8643</link>
    <description>&lt;P&gt;Wolf,&lt;/P&gt;&lt;P&gt;I have already done everything that you suggested regarding the Module class.&amp;nbsp; I also have 'autoLoad' set to true in the config.daml.&amp;nbsp; I followed all of the directions in the configurable extensions section of the link that you included. Unfortunately, however, that only helps me when Pro starts up (as you mentioned).&amp;nbsp; I need to be able to track when the license expires while Pro is still running.&amp;nbsp; The user may not shut the application down and just leave it running past the license timeout.&amp;nbsp; This is why I need to tie into some kind of event that is always polling like the button OnUpdate.&amp;nbsp; Is there anything that I can do like that?&lt;/P&gt;</description>
    <pubDate>Wed, 24 Aug 2022 16:55:51 GMT</pubDate>
    <dc:creator>DaveLewis73</dc:creator>
    <dc:date>2022-08-24T16:55:51Z</dc:date>
    <item>
      <title>How to Track Licensing for a Custom Extension</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-track-licensing-for-a-custom-extension/m-p/1205921#M8641</link>
      <description>&lt;P&gt;I have developed a custom external extension/add-in in ArcGIS Pro 2.9 that is available in the Licensing section.&amp;nbsp; I have a number of days until the extension (add-in) will time out.&amp;nbsp; However, I don't have an ideal way to track the count down of days and ultimately lock down the code for the extension when the license expires.&amp;nbsp; Is there an event that I can key off of that runs in the background, like the button OnUpdate event?&amp;nbsp; I could tie into this event and then know when the number of licensing days has expired and I can disable the extension.&amp;nbsp; I would use the button OnUpdate event, but as far as I can tell that requires that the tab that the button is located on to be active for the event to fire.&amp;nbsp; I need something to key off of that would execute all the time that the application is running.&lt;/P&gt;&lt;P&gt;Please let me know if any further information is required.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 16:13:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-track-licensing-for-a-custom-extension/m-p/1205921#M8641</guid>
      <dc:creator>DaveLewis73</dc:creator>
      <dc:date>2022-08-24T16:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to Track Licensing for a Custom Extension</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-track-licensing-for-a-custom-extension/m-p/1205933#M8642</link>
      <description>&lt;P&gt;Your Module class implementation is a singleton and hence should be home of your license time out code (just add your code in the Module class constructor).&amp;nbsp; By default, the Module class is executed just-in-time (JIT) when a user is using the add-in or the class is always instantiated when Pro starts up, if the 'autoLoad' attribute in the 'insertModule' tag is set to 'true' in the config.daml (see:&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Framework#declaring-modules-in-daml" target="_blank"&gt;ProConcepts Framework · Esri/arcgis-pro-sdk Wiki (github.com)&lt;/A&gt;)&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also there's some information about ArcGIS Pro Add-in licensing - maybe not applicable for your use case:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-License-Your-Add-in" target="_blank"&gt;ProGuide License Your Add in · Esri/arcgis-pro-sdk Wiki (github.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 16:40:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-track-licensing-for-a-custom-extension/m-p/1205933#M8642</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2022-08-24T16:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to Track Licensing for a Custom Extension</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-track-licensing-for-a-custom-extension/m-p/1205945#M8643</link>
      <description>&lt;P&gt;Wolf,&lt;/P&gt;&lt;P&gt;I have already done everything that you suggested regarding the Module class.&amp;nbsp; I also have 'autoLoad' set to true in the config.daml.&amp;nbsp; I followed all of the directions in the configurable extensions section of the link that you included. Unfortunately, however, that only helps me when Pro starts up (as you mentioned).&amp;nbsp; I need to be able to track when the license expires while Pro is still running.&amp;nbsp; The user may not shut the application down and just leave it running past the license timeout.&amp;nbsp; This is why I need to tie into some kind of event that is always polling like the button OnUpdate.&amp;nbsp; Is there anything that I can do like that?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 16:55:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-track-licensing-for-a-custom-extension/m-p/1205945#M8643</guid>
      <dc:creator>DaveLewis73</dc:creator>
      <dc:date>2022-08-24T16:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to Track Licensing for a Custom Extension</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-track-licensing-for-a-custom-extension/m-p/1205960#M8645</link>
      <description>&lt;P&gt;Understood.&amp;nbsp; In the Module class startup just check how much time is left and set a timer event using the time left.&amp;nbsp; When the time is up disable your state/condition for the UI.&lt;/P&gt;&lt;P&gt;In the Module class you define the timer in the ctor i just one minute in my snippet:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public Module1()
{
  // set Timer ...
  var timer = new System.Timers.Timer(60000); // set milliseconds delay
  timer.Elapsed += Timer_Elapsed;
  timer.Start();
  //activates the state
  FrameworkApplication.State.Activate(timerStateId);
}

private static string timerStateId = "timer_state";

private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
  if (FrameworkApplication.State.Contains(timerStateId))
  {
    //deactivates the state
    FrameworkApplication.State.Deactivate(timerStateId);
  }
  else
  {
    //activates the state
    FrameworkApplication.State.Activate(timerStateId);
  }
}&lt;/LI-CODE&gt;&lt;P&gt;Define the state in config.daml under the conditions tag and add the condition attribute to your UI element like buttons, groups, tools:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;...
&amp;lt;/AddInInfo&amp;gt;
&amp;lt;conditions&amp;gt;
  &amp;lt;!-- our custom condition --&amp;gt;
  &amp;lt;insertCondition id="timer_state_condition" caption="Timer state"&amp;gt;
    &amp;lt;!-- our condition is set true or false based on this underlying state --&amp;gt;
    &amp;lt;state id="timer_state" /&amp;gt;
  &amp;lt;/insertCondition&amp;gt;
&amp;lt;/conditions&amp;gt;
&amp;lt;modules&amp;gt;
...
  &amp;lt;tool id="MapT..."
      condition="timer_state_condition"&amp;gt;
...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 22:36:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-track-licensing-for-a-custom-extension/m-p/1205960#M8645</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2022-08-24T22:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to Track Licensing for a Custom Extension</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-track-licensing-for-a-custom-extension/m-p/1206323#M8649</link>
      <description>&lt;P&gt;Wolf,&lt;/P&gt;&lt;P&gt;The following is the timer code that I came up with, which seems to work.&amp;nbsp; I didn't see that you had included a snippet until just now.&amp;nbsp; I placed this in my Module (Module1).&amp;nbsp; It calls a method called "CheckLicensing" which does all of the condition checking and a little bit more.&amp;nbsp; The timeout is 1 second at the moment, but that can certainly be changed to every minute, hour, or whatever.&amp;nbsp; Is this sufficient?&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private DispatcherTimer _licenseTimer = null;

private void LicenseTimer_Tick(object sender, EventArgs e)
{
    if (Current.State == ExtensionState.Enabled)
    {
        CheckLicensing(false);
    }
}

protected override bool Initialize()
{
    _licenseTimer = new DispatcherTimer();
    _licenseTimer.Tick += new EventHandler(LicenseTimer_Tick);
    _licenseTimer.Interval = new TimeSpan(0, 0, 1);
    _licenseTimer.Start();

    return true;
}

protected override void Uninitialize()
{
    base.Uninitialize();

    if (_licenseTimer != null) { _licenseTimer.Stop(); }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 14:00:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-track-licensing-for-a-custom-extension/m-p/1206323#M8649</guid>
      <dc:creator>DaveLewis73</dc:creator>
      <dc:date>2022-08-25T14:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to Track Licensing for a Custom Extension</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-track-licensing-for-a-custom-extension/m-p/1206366#M8651</link>
      <description>&lt;P&gt;That will work for sure, but as an optimization i would check the licensing only once at startup and return the time span left before the license expires.&amp;nbsp; Using the returned timespan i would then set the duration for one single timer event.&amp;nbsp; This is a bit more optimized compared to calling your license checking code every second.&amp;nbsp; Using DispatchTimer as compared to Timer will work fine, it will ensure that your event code runs on the UI thread.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 15:35:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-track-licensing-for-a-custom-extension/m-p/1206366#M8651</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2022-08-25T15:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to Track Licensing for a Custom Extension</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-track-licensing-for-a-custom-extension/m-p/1206370#M8652</link>
      <description>&lt;P&gt;Wolf,&lt;/P&gt;&lt;P&gt;I am not sure that I am getting what you are suggesting.&amp;nbsp; Could you include a snippet?&amp;nbsp; I would really appreciate it.&amp;nbsp; Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 15:41:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-track-licensing-for-a-custom-extension/m-p/1206370#M8652</guid>
      <dc:creator>DaveLewis73</dc:creator>
      <dc:date>2022-08-25T15:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to Track Licensing for a Custom Extension</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-track-licensing-for-a-custom-extension/m-p/1206383#M8653</link>
      <description>&lt;P&gt;You have two scenarios:&lt;/P&gt;&lt;P&gt;1) your add-in starts and the license is already timed out, hence you disable your add-in features&lt;/P&gt;&lt;P&gt;2) your add-in starts and the license will expire in x minutes after startup.&amp;nbsp; Use the x minutes to setup your single timer event and when the event occurs you disable your add-in features.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 16:17:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-track-licensing-for-a-custom-extension/m-p/1206383#M8653</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2022-08-25T16:17:57Z</dc:date>
    </item>
  </channel>
</rss>

