Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Sep 21, 2019 2:45 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Using thread
PostPosted: Tue Jul 17, 2012 7:23 am 
Offline

Joined: Tue Jun 07, 2011 5:35 pm
Posts: 21
I have a Windows application that converts Microsoft works files from(wks to rtf). The routine is working but the GUI of course becomes non responsive while files are being converted. Wanted to provide progress info in the main window, I decided to put the main converter method inside a thread.

Below is code in the Thread

Dim wapp as WordApplication
Dim wdoc as WordDocument
Dim param_fname as variant
Dim param_saveas as variant
Dim param_confirmConversion as Variant
Dim f as FolderItem
Dim new_name as string
Dim f_extension as string
Dim numof_files as integer

If win_main.cbox_type.ListIndex=0 then
param_saveas=Office.wdFormatDocument
f_extension=".doc"
else
param_saveas=Office.wdFormatRTF
f_extension=".rtf"
End If

wapp=new WordApplication
wapp.visible=false
'Documents.open(filename, confirmConversion)]

For i as integer = 0 to win_main.lbox_files.ListCount -1

numof_files=numof_files + 1
win_main.int_list_item=numof_files
new_name=replace( win_main.lbox_files.list(i) ,".wps",f_extension)
wdoc=wapp.Documents.open(win_main.lbox_files.list(i),false)
wdoc.saveas(new_name,param_saveas)
wdoc.close
app.YieldToNextThread
Next

wapp.Quit


numof_files=numof_files + 1 is a property of win_main. I have set a timer in win_main to update the label on win_main.

The code (below) that changes the label [timer is supposed to update label] only runs after all files have been converted and of course the window is still unresponsive.
lbl_status.Text=str(int_list_item) + " files converted"



Any suggestions as to how I might possibly get the update code in win_main to update as each file is being processed.

Thanks in advance.

_________________
Using RealBasic Professional Edition 2011 Release 2


Top
 Profile  
Reply with quote  
 Post subject: Re: Using thread
PostPosted: Tue Jul 17, 2012 9:23 pm 
Offline

Joined: Wed Feb 16, 2011 1:59 pm
Posts: 74
Location: Arizona, USA
I think you're following something similar to the following: http://www.realsoftwareblog.com/2012/05 ... right.html
But have a read just in case.

int_list_item is a property of the win_main?

_________________
Windows XP SP3
RS 2012r2


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group