Alpha DevCon 2018
Results 1 to 5 of 5

Thread: run script within thread

  1. #1
    Member
    Real Name
    Steven Greer
    Join Date
    Jun 2008
    Location
    Manchester,PA
    Posts
    374

    Default run script within thread

    I have a script that takes a screenshot and saves to a file, it works on it's own outside of creating a separate thread. Meaning if I try to run the same code with in a thread it writes a 0 size bmp file. I'm trying to have a thread run in the background and run the script and then upload to ftp... The file uploads correctly so I have tested both ends of the thread and script, I just can't seem to get the screenshot code to work when I run it outside the Main Thread.
    Here is the script to start the thread.

    Code:
    thread_create(thread_name_create("shot"),<<%code%
     start:
    script_play_local("makeScreenshot")
    cmd = <<%a%
    connect|blah
    login|blah|blahblah
    cd|/srv/ftp/
    binary
    put|%a%""+fname+ crlf() + <<%a%
    quit 
    %a% 
    ftp_script_run_silent(cmd, .f.)
     sleep(30)
     
    goto start
    %code%)
    Here is the script makeScreenshot
    Code:
    dim ss as B
    dim ptr as P
    dim shared fname as c
    dim shared ctnr as n
    ctnr=1
    ctnr=ctnr+1
    fname="c:\housing\ss\ss"+ctnr+".bmp"
    ui_bitmap_create_from_screen("test", 0, 0, 30,8)
    
    ss = ui_bitmap_save("test")
    
    ptr = file.create(fname, FILE_RW_EXCLUSIVE)
    ptr.writeb(ss)
    ptr.close()
    ui_bitmap_drop("test")

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,948

    Default Re: run script within thread

    I think most would make the makescreenshot script into a function and call it from the other script.
    There can be only one.

  3. #3
    Member
    Real Name
    Steven Greer
    Join Date
    Jun 2008
    Location
    Manchester,PA
    Posts
    374

    Default Re: run script within thread

    I made the Makescreenshot into a script and it's still coming back with 0 byte empty files.I need to have this run outside the Main Thread so that it doesn't interrupt the user interface.

  4. #4
    Alpha Software Employee Lenny Forziati's Avatar
    Real Name
    Lenny Forziati
    Join Date
    Nov 2001
    Location
    Alpha Software
    Posts
    4,625

    Default Re: run script within thread

    Threads cannot interact with the user interface, so ui_bitmap_create_from_screen() cannot be used in a thread.

    Lenny Forziati
    Vice President, Internet Products and Technical Services
    Alpha Software Corporation

  5. #5
    Member
    Real Name
    Steven Greer
    Join Date
    Jun 2008
    Location
    Manchester,PA
    Posts
    374

    Default Re: run script within thread

    ok I was thinking that this morning that it prob doesn't work outside the Main thread.

Similar Threads

  1. Thread using too much CPU
    By imjoken in forum Mobile & Browser Applications
    Replies: 0
    Last Post: 02-01-2015, 11:31 AM
  2. Running a script in own thread
    By steve745 in forum Alpha Five Version 9 - Desktop Applications
    Replies: 2
    Last Post: 01-04-2010, 12:19 PM
  3. New thread, same ole PO app
    By Schulzie in forum Alpha Five Version 4
    Replies: 6
    Last Post: 07-07-2001, 03:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •