473,466 Members | 1,381 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Thread management

Hello,

I’m using a multithreaded windows service to listen a file directory and
process TIF documents.
For example if user drops 3 files to the directory,
“fileSystemWatcher_Created” event will create 3 threads.
Each thread has to process the same function.

1. Decompress file
2. Read text data from the TIF image (I’m are using “LEAD Technologies OCR
component”
3. Create new document record in database

For each call to rasterOcr.StartUp() there must be a call to the
RasterOcr.ShutDown method.
Now I run into problem. My first thread didn’t finish process and didn’t
call RasterOcr.ShutDown method, but the second one trying to call StartUp.

What should I do? How can I manage them. Please point me to the right
direction.

To read data from the image I’m doing something like this.

Public Shared Function ScanFaxImage(ByVal path As String) As String
Dim rasterOcr As New rasterOcr
Dim codecs As RasterCodecs
Dim rasterImage As IRasterImage
Dim recognizedChars() As RasterOcrRecognizedCharacters

RasterSupport.Unlock(RasterSupportType.Ocr, _
ApolloScanSettings.OCRSupportKey)

rasterOcr.StartUp()

codecs = LoadCodecs()
rasterImage = codecs.Load(path)

'Add the cover sheet of the fax
rasterOcr.AddPage(rasterImage, 0)
rasterOcr.AutoOrientPage(0)
rasterOcr.EnableZoneForceSingleColumn = True
rasterOcr.ShowZoneGridLines = False

'Automatically find zones
rasterOcr.FindZones(0)

'Scan the image for recognize characters and return result

rasterOcr.ShutDown()
End Function
Nov 23 '05 #1
1 1920
ValK,

Why are you calling RasterSupport.Unlock in the ScanFaxImage method?
That method gets executed several times right? I have no idea how this
OCR component works so I might be way off base, but do you really need
to make that call over and over again?

The rasterOcr variable is local to the method so each thread running
ScanFaxImage will be using a different instance. It shouldn't matter
that the first thread didn't call ShutDown on its own instance because
the second thread is using a completely different instance. Is there a
problem with the second thread calling StartUp?

Also, why are using multiple threads? Is it not easier to just process
the files serially?

Brian

ValK wrote:
Hello,

I'm using a multithreaded windows service to listen a file directory and
process TIF documents.
For example if user drops 3 files to the directory,
"fileSystemWatcher_Created" event will create 3 threads.
Each thread has to process the same function.

1. Decompress file
2. Read text data from the TIF image (I'm are using "LEAD Technologies OCR
component"
3. Create new document record in database

For each call to rasterOcr.StartUp() there must be a call to the
RasterOcr.ShutDown method.
Now I run into problem. My first thread didn't finish process and didn't
call RasterOcr.ShutDown method, but the second one trying to call StartUp.

What should I do? How can I manage them. Please point me to the right
direction.

To read data from the image I'm doing something like this.

Public Shared Function ScanFaxImage(ByVal path As String) As String
Dim rasterOcr As New rasterOcr
Dim codecs As RasterCodecs
Dim rasterImage As IRasterImage
Dim recognizedChars() As RasterOcrRecognizedCharacters

RasterSupport.Unlock(RasterSupportType.Ocr, _
ApolloScanSettings.OCRSupportKey)

rasterOcr.StartUp()

codecs = LoadCodecs()
rasterImage = codecs.Load(path)

'Add the cover sheet of the fax
rasterOcr.AddPage(rasterImage, 0)
rasterOcr.AutoOrientPage(0)
rasterOcr.EnableZoneForceSingleColumn = True
rasterOcr.ShowZoneGridLines = False

'Automatically find zones
rasterOcr.FindZones(0)

'Scan the image for recognize characters and return result

rasterOcr.ShutDown()
End Function


Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: John Doe | last post by:
Hi all, I know the standard doesn't care about threads (wrongly :-) But in current compilers implementation, is the "list" which holds count of the occupied and free heap addresses SHARED among...
5
by: Kishore Gopalan | last post by:
Hi, I'm using thread from a .NET Thread pool. And I assign some data in the thread during the time of its processing in Thread Local Storage. When the process gets over and the thread goes back...
0
by: Thunder$truck | last post by:
Hi, I'm trying to use a WMI script in a VB.NET application to query for a perticular process running and return it's threadcount to the application. I was hoping I could simply substitute:...
4
by: skip | last post by:
I would like to try a sampling approach to profiling. My thought is to have a profiling thread that samples the execution frame of all the other started threads. I don't see any path from the...
11
by: Michael Moreno | last post by:
Hello, I have a C# server which has 4 worker threads running all the time. When I let the server runs for several hours, for some reasons the CPU usage of the application will shoot to 100% and...
22
by: Morpheus | last post by:
Hi, I have been coding in Windows for many years so have a mindset to it, so forgive any stupid questions. Is it possible to create a multithread application in C++ that is portable...
34
by: Creativ | last post by:
Why does Thread class not support IDisposable? It's creating quite some problem. Namely, it can exhaust the resource and you have not control over it.
20
by: =?ISO-8859-1?Q?Gerhard_H=E4ring?= | last post by:
John Dohn wrote: When I do this, I put a special value in the queue (like None) and in the worker thread, check for the special value and exit if found. Threads can also be marked as "daemon...
44
by: climber.cui | last post by:
Hi all, Does anyone have experience on the thread-safty issue with malloc()? Some people said this function provided in stdlib.h is not thread- safe, but someone said it is thread safe. Is it...
9
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I've got a routine that builds a table using different queries, different SQL Tables, and adding custom fields. It takes a while to run (20 - 45 seconds) so I wrote a thread to handle the table...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.