Highlighted
Super Contributor.
Super Contributor.
1083 views

Message Wait....

I'm needing to show a message wait, searched the web but only found in C # using Threads, does anyone have an example of how to do?

0 Likes
2 Replies
Highlighted
Super Contributor.
Super Contributor.

RE: Message Wait....

      CLASS-ID MyClass.

      WORKING-STORAGE SECTION.

        01  pleaseWaitForm            type PleaseWaitDlg.

      METHOD-ID BuildTables.

      LOCAL-STORAGE SECTION.

        01  threadStart               type System.Threading.ThreadStart.

        01  aThread                   type System.Threading.Thread.

      PROCEDURE DIVISION.

          set threadStart to new System.Threading.ThreadStart(self::MyProcess())

          set aThread to new type System.Threading.Thread(threadStart)

          set aThread::IsBackground to true

          invoke aThread::Start()

          set pleaseWaitForm to new type PleaseWaitDlg

          invoke pleaseWaitForm::ShowDialog()

          GOBACK.

      END METHOD.

      METHOD-ID MyProcess.

      PROCEDURE DIVISION.

          Do some processing

          invoke type System.Threading.Thread::Sleep(500)

          set pleaseWaitForm::ShouldCloseNow to true

          GOBACK.

      END METHOD.

      END CLASS.

  This is the form that displays "Please Wait ...".

  Select a timer control from the toolbox (All Windows Forms ... Timer) and place

  it on the form, then create an event hander (tmrCheckIfNeedToCloseDialog_Tick)

  for its Tick event.

     $set ilusing"System"

     $set ilusing"System.Collections.Generic"

     $set ilusing"System.ComponentModel"

     $set ilusing"System.Data"

     $set ilusing"System.Drawing"

     $set ilusing"System.Text"

     $set ilusing"System.Windows.Forms"

      class-id PleaseWaitDlg is partial

                inherits type System.Windows.Forms.Form.

      working-storage section.

          01  ShouldCloseNow      type Boolean property.

      method-id NEW.

      procedure division.

          invoke self::InitializeComponent()

          goback.

      end method.

      method-id PleaseWaitDlg_Load final private.

      procedure division using by value sender as object e as type System.EventArgs.

          set ShouldCloseNow to false

          set self::Cursor to type Cursors::WaitCursor

          invoke self::tmrCheckIfNeedToCloseDialog::Start()

      end method.

      method-id tmrCheckIfNeedToCloseDialog_Tick final private.

      procedure division using by value sender as object e as type System.EventArgs.

          if ShouldCloseNow = true

              set self::Cursor to type Cursors::Default

              invoke self::Close()

      end method.

      end class.

Phil Levin

0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Message Wait....

I'll do a test, thank you

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.