- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I try to write to a file(unit 50) from one thread and after the write command I do an invalidaterect to update the user interface to display the contents of the file by reading from the same file(unit 50) which happens with the main program thread(in WM_PAINT).I get run time error 40 on execution.
Runtime error 40 as you know is for:Recursive I/O operation.
FOR$IOS_RECIO_OPE. While processing an I/O statement for a logical unit, another I/O operation on the same logical unit was attempted, such as a function subprogram that performs I/O to the same logical unit that was referenced in an expression in an I/O list or variable format expression.
I tried giving a suitable delay after the write before the call to invalidaterect, but this didn't work.Can someone suggest a way to solve this problem. Thanks
Archana.
I try to write to a file(unit 50) from one thread and after the write command I do an invalidaterect to update the user interface to display the contents of the file by reading from the same file(unit 50) which happens with the main program thread(in WM_PAINT).I get run time error 40 on execution.
Runtime error 40 as you know is for:Recursive I/O operation.
FOR$IOS_RECIO_OPE. While processing an I/O statement for a logical unit, another I/O operation on the same logical unit was attempted, such as a function subprogram that performs I/O to the same logical unit that was referenced in an expression in an I/O list or variable format expression.
I tried giving a suitable delay after the write before the call to invalidaterect, but this didn't work.Can someone suggest a way to solve this problem. Thanks
Archana.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you linking against the multithreaded library?
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a single application in which I have created several threads.This is the sequence of execution:
This subroutine tries to write to the end of the file:
It's called from a thread.
subroutine writestring(text)
read(50,*,iostat=io)
do while(io .eq. 0)
read(50,*,iostat=io)
enddo
write(50,'(a)')trim(text)
vscrollmax=vscrollmax+1 //indicates maximum scrolling range and the size of the file
dummyI = InvalidateRect( ghwndMain, NULL_RECT, .TRUE. )
end subroutine writestring
****************************************
and WM_PAINT tries to do the following:
do i=1,40
backspace(50)
if(io.eq.0)toplinenumber=toplinenumber+1
enddo
do j=1,40
text=' '
read(50,'(a)',iostat=io)text
ncols=len_trim(text)
dummyL=textout(hdc,nDrawX,nDrawY,text,ncols)
nDrawY =nDrawY+font_ht
enddo
************************************
So the thread calls the writestring subroutine several times during its executing.This is when there is some overlap in the read statement from two different places but from the same file.
Will it be better if I program to store the contents of the file in a buffer and try to display the text on repaint(scrolling,adding text,etc) from the buffer instead of trying to read from the file everytime.
Thanks,
Archana
This subroutine tries to write to the end of the file:
It's called from a thread.
subroutine writestring(text)
read(50,*,iostat=io)
do while(io .eq. 0)
read(50,*,iostat=io)
enddo
write(50,'(a)')trim(text)
vscrollmax=vscrollmax+1 //indicates maximum scrolling range and the size of the file
dummyI = InvalidateRect( ghwndMain, NULL_RECT, .TRUE. )
end subroutine writestring
****************************************
and WM_PAINT tries to do the following:
do i=1,40
backspace(50)
if(io.eq.0)toplinenumber=toplinenumber+1
enddo
do j=1,40
text=' '
read(50,'(a)',iostat=io)text
ncols=len_trim(text)
dummyL=textout(hdc,nDrawX,nDrawY,text,ncols)
nDrawY =nDrawY+font_ht
enddo
************************************
So the thread calls the writestring subroutine several times during its executing.This is when there is some overlap in the read statement from two different places but from the same file.
Will it be better if I program to store the contents of the file in a buffer and try to display the text on repaint(scrolling,adding text,etc) from the buffer instead of trying to read from the file everytime.
Thanks,
Archana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Will it be better if I program to store the contents of the file in a buffer and try to display the text on repaint(scrolling,adding text,etc) from the buffer instead of trying to read from the file everytime.
Definitely yes -- for an order of magnitude.
Definitely yes -- for an order of magnitude.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page