Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: Message Wait....

$
0
0

      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.


Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>