<?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: Enterprise Guide 7.1 - Vb.Net Custom Task using RunLater - Frame didn't close at first button hi in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Enterprise-Guide-7-1-Vb-Net-Custom-Task-using-ShowResult/m-p/438925#M28358</link>
    <description>&lt;P&gt;Thanks for buying the book -- and good luck with your custom tasks.&amp;nbsp; Build something amazing!&lt;/P&gt;</description>
    <pubDate>Wed, 21 Feb 2018 14:02:42 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2018-02-21T14:02:42Z</dc:date>
    <item>
      <title>Enterprise Guide 7.1 - Vb.Net Custom Task using ShowResult.RunLater</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Enterprise-Guide-7-1-Vb-Net-Custom-Task-using-ShowResult/m-p/438575#M28323</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;first, please excuse my untrained english. In addition i am not experierenced posting in forums. Hopefully i post my problem on the right place.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will develop a Custom Task Gui&amp;nbsp; with the 3 button:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Button "Save" calls ShowREsult.Runlater&amp;nbsp; (save settings, close the Frame and let the Custom Taks&amp;nbsp; on the processflow)&lt;/LI&gt;
&lt;LI&gt;Button "Start"&amp;nbsp; calls ShowResult.RunNow (start some sas-code, close the frame without saving settings)&lt;/LI&gt;
&lt;LI&gt;Button "Cancel" calls ShowResult.Canceld (close frame wihout saveing setting)&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;and tried&amp;nbsp; to use it in the overrided Show function in this was:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;(Exerpt from VB-Code:)&lt;BR /&gt;    Private show_Counter As Integer = 0&lt;BR /&gt;&lt;BR /&gt;    Public Overrides Function Show(ByVal Owner As IWin32Window) As ShowResult

        Dim dlg As Class1Form = New Class1Form()

        show_Counter = show_Counter + 1

        _logger.Debug(String.Format("{0} Button {1} Show Counter {2}", System.Reflection.MethodBase.GetCurrentMethod().Name, dlg.ShowDialog(Owner), show_Counter.ToString))

        If (DialogResult.OK = dlg.ShowDialog(Owner)) Then
            _logger.Debug(String.Format("{0} RunNow", System.Reflection.MethodBase.GetCurrentMethod().Name))
            Return ShowResult.RunNow
        ElseIf (DialogResult.Yes = dlg.ShowDialog(Owner)) Then
            _logger.Debug(String.Format("{0} RunLater", System.Reflection.MethodBase.GetCurrentMethod().Name))
            Return ShowResult.RunLater
        Else
            _logger.Debug(String.Format("{0} Canceld", System.Reflection.MethodBase.GetCurrentMethod().Name))
            Return ShowResult.Canceled
        End If

    End Function&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basicly the functionality works (RunLater, RunNow, Canceled) but i have to hit the buttons repeatedly - up to 3-5 times.&lt;/P&gt;
&lt;P&gt;Logging shows that the Show function runs just once (only one occurence from result "_logger.Debug(String.Format("{0} Button {1} Show Counter {2}"....")&amp;nbsp; :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;(Exerpt from the EG-Log):&lt;BR /&gt;2018-02-20 09:47:54,508 [Main] DEBUG ClassLibrary1.Class1 [(null)] - Show Button Yes Show Counter 1
2018-02-20 09:47:56,605 [Main] DEBUG ClassLibrary1.Class1 [(null)] - Show RunLater&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope that ich posted my problem not to clouded and that&amp;nbsp;someone can help me. Thanks a lot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regrads,&lt;/P&gt;
&lt;P&gt;Michael&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2018 14:03:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Enterprise-Guide-7-1-Vb-Net-Custom-Task-using-ShowResult/m-p/438575#M28323</guid>
      <dc:creator>mk_methrada</dc:creator>
      <dc:date>2018-02-21T14:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: Enterprise Guide 7.1 - Vb.Net Custom Task using RunLater - Frame didn't close at first button hi</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Enterprise-Guide-7-1-Vb-Net-Custom-Task-using-ShowResult/m-p/438629#M28329</link>
      <description>&lt;P&gt;In addition to returning one of the&amp;nbsp;ShowResult values, your VB form also needs to have logic that closes the window when one of those buttons is clicked.&amp;nbsp; For OK-style buttons and Cancel-style buttons, you can associate the AcceptButton and CancelButton properties with those button IDs as well as the DialogResult value (OK and Cancel, respectively), and that will wired up the Close action.&amp;nbsp; For "RunLater", you probably need to add logic that calls Close() on the displayed form so that the window is dismissed.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2018 13:10:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Enterprise-Guide-7-1-Vb-Net-Custom-Task-using-ShowResult/m-p/438629#M28329</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-02-20T13:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: Enterprise Guide 7.1 - Vb.Net Custom Task using RunLater - Frame didn't close at first button hi</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Enterprise-Guide-7-1-Vb-Net-Custom-Task-using-ShowResult/m-p/438886#M28353</link>
      <description>&lt;P&gt;Dear Chris,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your quick reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the buttons "Start" (ShowResult.RunNow)&amp;nbsp; and "Cancel" ((ShowResult.Canceld) the property DialogResult is set to "OK" and "CANCEL". On the form the properties AcceptButton is assigned to Button "Start" and CancelButton is assigned to Button "Cancel".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the Button "Save" (ShowResult.RunLater) i added the function "btn_Save_Click" and perform "me.close()".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The behaviour did not change. When i hit one of the buttons, it needs 2 hits on "Start" and 3 hits on the other buttons before the form is closed.&lt;/P&gt;&lt;P&gt;Here an excerpt from the log when i test the "Save" button (please find the whole log in the attachement):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;2018-02-21 09:03:32,778 [Main] DEBUG RunLater.RunLater [(null)] - [.ctor] calls InitializeComponent()
2018-02-21 09:03:32,779 [Main] DEBUG RunLater.RunLater [(null)] - [InitializeComponent]
2018-02-21 09:03:32,779 [Main] INFO  SAS.Shared.AddIns.Management.AddInProxy [(null)] - Creating AddInProxy for RunLater.RunLater, C:\Users\micha_2\AppData\Roaming\SAS\EnterpriseGuide\7.1\Custom\RunLater.dll
2018-02-21 09:03:32,806 [Main] DEBUG RunLater.RunLaterForm [(null)] - [.ctor] calls InitializeComponent() and get settings ...
2018-02-21 09:03:40,090 [Main] DEBUG RunLater.RunLaterForm [(null)] - [btn_Save_Click] Hits: 1
2018-02-21 09:03:40,091 [Main] DEBUG RunLater.RunLaterForm [(null)] - [OnClosed] DialogResult=Yes 
2018-02-21 09:03:40,145 [Main] DEBUG RunLater.RunLater [(null)] - [Show] dlg.ShowDialog(Owner)=Yes show_Counter=1
2018-02-21 09:03:50,411 [Main] DEBUG RunLater.RunLaterForm [(null)] - [btn_Save_Click] Hits: 2
2018-02-21 09:03:50,411 [Main] DEBUG RunLater.RunLaterForm [(null)] - [OnClosed] DialogResult=Yes 
2018-02-21 09:04:01,636 [Main] DEBUG RunLater.RunLaterForm [(null)] - [btn_Save_Click] Hits: 3
2018-02-21 09:04:01,636 [Main] DEBUG RunLater.RunLaterForm [(null)] - [OnClosed] DialogResult=Yes 
2018-02-21 09:04:01,696 [Main] DEBUG RunLater.RunLater [(null)] - [Show] RunLater
2018-02-21 09:04:01,702 [Main] DEBUG RunLater.RunLater [(null)] - [GetXmlState]
2018-02-21 09:04:01,702 [Main] DEBUG RunLater.RunLaterSettings [(null)] - [toXML] doc.OuterXml=&amp;lt;Class1 Text="test" /&amp;gt;
2018-02-21 09:05:20,100 [Main] DEBUG SAS.EG.ProjectElements.GitRepository [(null)] - Disposing
2018-02-21 09:05:20,100 [Main] DEBUG SAS.EG.ProjectElements.GitRepository [(null)] - Attempting to delete C:\Users\micha_2\AppData\Local\Temp\SEG13764\isfFXPqAuqbiqVNH&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;[OnClosed] and [Show] are the overridden funktion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you habe any more ideas, what i have done wrong? In addition i have appended the RunLater Project&amp;nbsp; (Visual Studio 2017) too and woud like to ask you whether Is it possible, that you take a brief look at the code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regrads&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2018 08:30:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Enterprise-Guide-7-1-Vb-Net-Custom-Task-using-ShowResult/m-p/438886#M28353</guid>
      <dc:creator>mk_methrada</dc:creator>
      <dc:date>2018-02-21T08:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: Enterprise Guide 7.1 - Vb.Net Custom Task using RunLater - Frame didn't close at first button hi</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Enterprise-Guide-7-1-Vb-Net-Custom-Task-using-ShowResult/m-p/438887#M28354</link>
      <description>&lt;P&gt;Sorry, the complete log has got lost in the previous post. Here it is .....&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2018 08:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Enterprise-Guide-7-1-Vb-Net-Custom-Task-using-ShowResult/m-p/438887#M28354</guid>
      <dc:creator>mk_methrada</dc:creator>
      <dc:date>2018-02-21T08:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: Enterprise Guide 7.1 - Vb.Net Custom Task using RunLater - Frame didn't close at first button hi</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Enterprise-Guide-7-1-Vb-Net-Custom-Task-using-ShowResult/m-p/438919#M28356</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/57578"&gt;@mk_methrada&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are a few things going on here.&amp;nbsp; With the current logic,&amp;nbsp;&lt;STRONG&gt;ShowDialog&lt;/STRONG&gt; is called multiple times as the code executes.&amp;nbsp; That accounts for the multiple clicks that you're perceiving -- you're actually dismissing&amp;nbsp;up to 4 different instances of the&amp;nbsp;dialog window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Each time you see&amp;nbsp;&lt;STRONG&gt;dlg.ShowDialog()&lt;/STRONG&gt; in this code, the window could be created/displayed.&amp;nbsp; That includes the&amp;nbsp;&lt;STRONG&gt;Debug&lt;/STRONG&gt; action you send to the logger!&amp;nbsp; Exactly how many times you see the window will depend on the logic of the If...Then...Else flow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        _logger.Debug(String.Format("[{0}] dlg.ShowDialog(Owner)={1} show_Counter={2}", System.Reflection.MethodBase.GetCurrentMethod().Name, dlg.ShowDialog(Owner), show_Counter.ToString))

        ' If Button Start is hit ....
        If (DialogResult.OK = dlg.ShowDialog(Owner)) Then
            _logger.Debug(String.Format("[{0}] RunNow", System.Reflection.MethodBase.GetCurrentMethod().Name))
            Return ShowResult.RunNow
        ElseIf (DialogResult.Yes = dlg.ShowDialog(Owner)) Then
            ' if Button Save is hit .....
            Settings = dlg.Settings
            _logger.Debug(String.Format("[{0}] RunLater", System.Reflection.MethodBase.GetCurrentMethod().Name))
            Return ShowResult.RunLater
        End If&lt;/PRE&gt;
&lt;P&gt;Here is a refactored version of the code that calls ShowDialog just once.&amp;nbsp; I left your other debugging statements intact.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;    Public Overrides Function Show(ByVal Owner As IWin32Window) As ShowResult

        Dim dlg As RunLaterForm = New RunLaterForm(Settings)

        show_Counter = show_Counter + 1

        _logger.Debug(String.Format("[{0}] show_Counter={1}", System.Reflection.MethodBase.GetCurrentMethod().Name, show_Counter.ToString))

        Select Case dlg.ShowDialog(Owner)
            Case DialogResult.OK
                _logger.Debug(String.Format("[{0}] RunNow", System.Reflection.MethodBase.GetCurrentMethod().Name))
                Return ShowResult.RunNow
            Case DialogResult.Yes
                ' if Button Save is hit .....
                Settings = dlg.Settings
                _logger.Debug(String.Format("[{0}] RunLater", System.Reflection.MethodBase.GetCurrentMethod().Name))
                Return ShowResult.RunLater
            Case DialogResult.Cancel
            Case Else
                ' all other like canceld ...
                _logger.Debug(String.Format("[{0}] Canceld", System.Reflection.MethodBase.GetCurrentMethod().Name))
                Return ShowResult.Canceled
        End Select
        Return ShowResult.Canceled
    End Function&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also: your project has references to&amp;nbsp;&lt;STRONG&gt;many&lt;/STRONG&gt; SAS Enterprise Guide DLLs, and you need only those that have the documented APIs:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;SAS.Shared.Addins.DLL&lt;/LI&gt;
&lt;LI&gt;SAS.Tasks.Toolkit.DLL&lt;/LI&gt;
&lt;LI&gt;log4net.dll (used for your debugging statements)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I would remove the other references, as this will make your project more portable/usable for future versions of EG.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you continue this pursuit, I recommend that you learn how to use the Visual Studio debugger.&amp;nbsp; It's an excellent tool, and setting proper breakpoints would have revealed exactly what's going on here.&amp;nbsp; You can use the&amp;nbsp;&lt;STRONG&gt;Debug&lt;/STRONG&gt;-&amp;gt;&lt;STRONG&gt;Attach to Process&lt;/STRONG&gt; feature to join the debugger to the running task "just in time" -- as long as the deployed custom task DLL and PDB (symbols) file are in the same folder.&amp;nbsp; If you're &lt;A href="https://www.sas.com/store/books/categories/usage-and-reference/custom-tasks-for-sas-enterprise-guide-using-microsoft-net/prodBK_61874_en.html" target="_self"&gt;working from my book about custom tasks&lt;/A&gt;, I have an entire chapter devoted to this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Update&lt;/STRONG&gt;: Just remembered I also &lt;A href="https://blogs.sas.com/content/sasdummy/2014/02/11/vs2013-express-custom-tasks/" target="_self"&gt;have a blog post about this debugging trick.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2018 13:12:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Enterprise-Guide-7-1-Vb-Net-Custom-Task-using-ShowResult/m-p/438919#M28356</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-02-21T13:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: Enterprise Guide 7.1 - Vb.Net Custom Task using RunLater - Frame didn't close at first button hi</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Enterprise-Guide-7-1-Vb-Net-Custom-Task-using-ShowResult/m-p/438923#M28357</link>
      <description>&lt;P&gt;Hi Chris,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;oh, how embarrassing &lt;img id="smileyfrustrated" class="emoticon emoticon-smileyfrustrated" src="https://communities.sas.com/i/smilies/16x16_smiley-frustrated.png" alt="Smiley Frustrated" title="Smiley Frustrated" /&gt;&amp;nbsp; A few weeks ago i bought your book and have also read the section about debugging, but not with the concentration you mentioned it. My fault, pardon me.&amp;nbsp; And yes, i have to go deeper in Vb .Net processes&amp;nbsp; ......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many, many thanks for your help, time and tipps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2018 13:42:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Enterprise-Guide-7-1-Vb-Net-Custom-Task-using-ShowResult/m-p/438923#M28357</guid>
      <dc:creator>mk_methrada</dc:creator>
      <dc:date>2018-02-21T13:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Enterprise Guide 7.1 - Vb.Net Custom Task using RunLater - Frame didn't close at first button hi</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Enterprise-Guide-7-1-Vb-Net-Custom-Task-using-ShowResult/m-p/438925#M28358</link>
      <description>&lt;P&gt;Thanks for buying the book -- and good luck with your custom tasks.&amp;nbsp; Build something amazing!&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2018 14:02:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Enterprise-Guide-7-1-Vb-Net-Custom-Task-using-ShowResult/m-p/438925#M28358</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-02-21T14:02:42Z</dc:date>
    </item>
  </channel>
</rss>

