473,729 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with threading

We have 109 remote offices all running Sybase ASA Server. We collect data
from these offices and consolidate it into our main server. I have written
a program that will read from each office and synchronize the data. It
takes a while to run because each office only has a 128k Frame Relay.

I have two database classes: one for accessing the office, one for accessing
the main server. The database classes expose simple functions of
connecting, updating and reading from the databases.

I have a class that operates the synchronization - imports tables in the
correct order and performs various checks on the data.

I have a program that calls the synchronization class sequentially for each
office.

It takes about 2 minutes per office, or about three hours to complete. I'd
like to run this program hourly, so I want to get the total run time down.

I've tried changing the program that calls the synchronization class to
start five threads, and keep five running. The problem I run into is that
the office database class appears to get shared between threads - I get the
same results back from what should be separate offices running in separate
threads.

How can I set it up so that each thread is entirely separate from the other
threads, including any support classes called by those threads?
Nov 20 '05 #1
6 1347
I would say, create the "office" database class within the newly started
thread, and make sure there is no
"Public Shared" variables or properties in that class.

Regards
Fredrik Melin

"Benjamin Walling" <bw******@latne dtsaoc-reverse.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
We have 109 remote offices all running Sybase ASA Server. We collect data
from these offices and consolidate it into our main server. I have written a program that will read from each office and synchronize the data. It
takes a while to run because each office only has a 128k Frame Relay.

I have two database classes: one for accessing the office, one for accessing the main server. The database classes expose simple functions of
connecting, updating and reading from the databases.

I have a class that operates the synchronization - imports tables in the
correct order and performs various checks on the data.

I have a program that calls the synchronization class sequentially for each office.

It takes about 2 minutes per office, or about three hours to complete. I'd like to run this program hourly, so I want to get the total run time down.

I've tried changing the program that calls the synchronization class to
start five threads, and keep five running. The problem I run into is that
the office database class appears to get shared between threads - I get the same results back from what should be separate offices running in separate
threads.

How can I set it up so that each thread is entirely separate from the other threads, including any support classes called by those threads?

Nov 20 '05 #2
That was the first thing I tried. There are no shared variables or
functions. Everything is private with the exception of the constructors.
"Fredrik Melin" <me*@n.o.spam.d acsa.net.remove .as.needed> wrote in message
news:B5******** ************@gi ganews.com...
I would say, create the "office" database class within the newly started
thread, and make sure there is no
"Public Shared" variables or properties in that class.

Regards
Fredrik Melin

"Benjamin Walling" <bw******@latne dtsaoc-reverse.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
We have 109 remote offices all running Sybase ASA Server. We collect data from these offices and consolidate it into our main server. I have

written
a program that will read from each office and synchronize the data. It
takes a while to run because each office only has a 128k Frame Relay.

I have two database classes: one for accessing the office, one for

accessing
the main server. The database classes expose simple functions of
connecting, updating and reading from the databases.

I have a class that operates the synchronization - imports tables in the
correct order and performs various checks on the data.

I have a program that calls the synchronization class sequentially for

each
office.

It takes about 2 minutes per office, or about three hours to complete.

I'd
like to run this program hourly, so I want to get the total run time down.
I've tried changing the program that calls the synchronization class to
start five threads, and keep five running. The problem I run into is that the office database class appears to get shared between threads - I get

the
same results back from what should be separate offices running in separate threads.

How can I set it up so that each thread is entirely separate from the

other
threads, including any support classes called by those threads?


Nov 20 '05 #3
Ah. Scratch that. I had made some shared functions. Seems to have
eliminated the problem. This had been driving me nuts!
"Benjamin Walling" <bw******@latne dtsaoc-reverse.com> wrote in message
news:uR******** *****@TK2MSFTNG P11.phx.gbl...
That was the first thing I tried. There are no shared variables or
functions. Everything is private with the exception of the constructors.
"Fredrik Melin" <me*@n.o.spam.d acsa.net.remove .as.needed> wrote in message
news:B5******** ************@gi ganews.com...
I would say, create the "office" database class within the newly started
thread, and make sure there is no
"Public Shared" variables or properties in that class.

Regards
Fredrik Melin

"Benjamin Walling" <bw******@latne dtsaoc-reverse.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
We have 109 remote offices all running Sybase ASA Server. We collect data from these offices and consolidate it into our main server. I have

written
a program that will read from each office and synchronize the data. It takes a while to run because each office only has a 128k Frame Relay.

I have two database classes: one for accessing the office, one for

accessing
the main server. The database classes expose simple functions of
connecting, updating and reading from the databases.

I have a class that operates the synchronization - imports tables in the correct order and performs various checks on the data.

I have a program that calls the synchronization class sequentially for

each
office.

It takes about 2 minutes per office, or about three hours to complete.

I'd
like to run this program hourly, so I want to get the total run time down.
I've tried changing the program that calls the synchronization class to start five threads, and keep five running. The problem I run into is that the office database class appears to get shared between threads - I
get
the
same results back from what should be separate offices running in

separate threads.

How can I set it up so that each thread is entirely separate from the

other
threads, including any support classes called by those threads?



Nov 20 '05 #4
Okay, I'm still going nuts.

I have a piece of data in the remote office that is an identifier for that
office. I can compare it to what I have in the central database.

I put a little block of code (using GetScalar) to check this each time
before I get a data reader. It checks correctly each time, however the data
in the reader still comes back from other offices. If I change the check
routine to use a data reader, it returns the incorrect office.

What is going on? Is the OLEDB DataReader object just unsafe in threads?
What should I do to get around this?

"Benjamin Walling" <bw******@latne dtsaoc-reverse.com> wrote in message
news:Ox******** ******@TK2MSFTN GP10.phx.gbl...
Ah. Scratch that. I had made some shared functions. Seems to have
eliminated the problem. This had been driving me nuts!
"Benjamin Walling" <bw******@latne dtsaoc-reverse.com> wrote in message
news:uR******** *****@TK2MSFTNG P11.phx.gbl...
That was the first thing I tried. There are no shared variables or
functions. Everything is private with the exception of the constructors.


"Fredrik Melin" <me*@n.o.spam.d acsa.net.remove .as.needed> wrote in message news:B5******** ************@gi ganews.com...
I would say, create the "office" database class within the newly started thread, and make sure there is no
"Public Shared" variables or properties in that class.

Regards
Fredrik Melin

"Benjamin Walling" <bw******@latne dtsaoc-reverse.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
> We have 109 remote offices all running Sybase ASA Server. We collect
data
> from these offices and consolidate it into our main server. I have
written
> a program that will read from each office and synchronize the data. It > takes a while to run because each office only has a 128k Frame
Relay. >
> I have two database classes: one for accessing the office, one for
accessing
> the main server. The database classes expose simple functions of
> connecting, updating and reading from the databases.
>
> I have a class that operates the synchronization - imports tables in

the > correct order and performs various checks on the data.
>
> I have a program that calls the synchronization class sequentially for each
> office.
>
> It takes about 2 minutes per office, or about three hours to complete. I'd
> like to run this program hourly, so I want to get the total run time

down.
>
> I've tried changing the program that calls the synchronization class to > start five threads, and keep five running. The problem I run into is that
> the office database class appears to get shared between threads - I get the
> same results back from what should be separate offices running in

separate
> threads.
>
> How can I set it up so that each thread is entirely separate from

the other
> threads, including any support classes called by those threads?
>
>



Nov 20 '05 #5
Hi again.

As far as I know, SQLDataReader is not thread safe, use DataSet's instead.

Regards
Fredrik Melin

"Benjamin Walling" <bw******@latne dtsaoc-reverse.com> wrote in message
news:e%******** ********@TK2MSF TNGP11.phx.gbl. ..
Okay, I'm still going nuts.

I have a piece of data in the remote office that is an identifier for that
office. I can compare it to what I have in the central database.

I put a little block of code (using GetScalar) to check this each time
before I get a data reader. It checks correctly each time, however the data in the reader still comes back from other offices. If I change the check
routine to use a data reader, it returns the incorrect office.

What is going on? Is the OLEDB DataReader object just unsafe in threads?
What should I do to get around this?

"Benjamin Walling" <bw******@latne dtsaoc-reverse.com> wrote in message
news:Ox******** ******@TK2MSFTN GP10.phx.gbl...
Ah. Scratch that. I had made some shared functions. Seems to have
eliminated the problem. This had been driving me nuts!
"Benjamin Walling" <bw******@latne dtsaoc-reverse.com> wrote in message
news:uR******** *****@TK2MSFTNG P11.phx.gbl...
That was the first thing I tried. There are no shared variables or
functions. Everything is private with the exception of the constructors.

"Fredrik Melin" <me*@n.o.spam.d acsa.net.remove .as.needed> wrote in message news:B5******** ************@gi ganews.com...
> I would say, create the "office" database class within the newly started > thread, and make sure there is no
> "Public Shared" variables or properties in that class.
>
> Regards
> Fredrik Melin
>
> "Benjamin Walling" <bw******@latne dtsaoc-reverse.com> wrote in message > news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
> > We have 109 remote offices all running Sybase ASA Server. We collect data
> > from these offices and consolidate it into our main server. I have > written
> > a program that will read from each office and synchronize the data.
It
> > takes a while to run because each office only has a 128k Frame Relay. > >
> > I have two database classes: one for accessing the office, one for
> accessing
> > the main server. The database classes expose simple functions of
> > connecting, updating and reading from the databases.
> >
> > I have a class that operates the synchronization - imports tables
in
the
> > correct order and performs various checks on the data.
> >
> > I have a program that calls the synchronization class sequentially for > each
> > office.
> >
> > It takes about 2 minutes per office, or about three hours to complete. > I'd
> > like to run this program hourly, so I want to get the total run
time down.
> >
> > I've tried changing the program that calls the synchronization

class to
> > start five threads, and keep five running. The problem I run into is that
> > the office database class appears to get shared between threads -
I get
> the
> > same results back from what should be separate offices running in
separate
> > threads.
> >
> > How can I set it up so that each thread is entirely separate from

the > other
> > threads, including any support classes called by those threads?
> >
> >
>
>



Nov 20 '05 #6
I started to change my code to use DataSet, but don't you need Connection &
Command objects to fill the dataset? Neither the Connection nor the Command
objects are thread safe.

Is there a thread safe way to get the data? (I have to use the OLEDB.*
objects in order to use the ASA Provider.)

"Fredrik Melin" <me*@n.o.spam.d acsa.net.remove .as.needed> wrote in message
news:Po******** ************@gi ganews.com...
Hi again.

As far as I know, SQLDataReader is not thread safe, use DataSet's instead.

Regards
Fredrik Melin

"Benjamin Walling" <bw******@latne dtsaoc-reverse.com> wrote in message
news:e%******** ********@TK2MSF TNGP11.phx.gbl. ..
Okay, I'm still going nuts.

I have a piece of data in the remote office that is an identifier for that
office. I can compare it to what I have in the central database.

I put a little block of code (using GetScalar) to check this each time
before I get a data reader. It checks correctly each time, however the data
in the reader still comes back from other offices. If I change the check routine to use a data reader, it returns the incorrect office.

What is going on? Is the OLEDB DataReader object just unsafe in threads? What should I do to get around this?

"Benjamin Walling" <bw******@latne dtsaoc-reverse.com> wrote in message
news:Ox******** ******@TK2MSFTN GP10.phx.gbl...
Ah. Scratch that. I had made some shared functions. Seems to have
eliminated the problem. This had been driving me nuts!
"Benjamin Walling" <bw******@latne dtsaoc-reverse.com> wrote in message
news:uR******** *****@TK2MSFTNG P11.phx.gbl...
> That was the first thing I tried. There are no shared variables or
> functions. Everything is private with the exception of the

constructors.
>
>
> "Fredrik Melin" <me*@n.o.spam.d acsa.net.remove .as.needed> wrote in

message
> news:B5******** ************@gi ganews.com...
> > I would say, create the "office" database class within the newly

started
> > thread, and make sure there is no
> > "Public Shared" variables or properties in that class.
> >
> > Regards
> > Fredrik Melin
> >
> > "Benjamin Walling" <bw******@latne dtsaoc-reverse.com> wrote in message > > news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
> > > We have 109 remote offices all running Sybase ASA Server. We

collect
> data
> > > from these offices and consolidate it into our main server. I have > > written
> > > a program that will read from each office and synchronize the data. It
> > > takes a while to run because each office only has a 128k Frame

Relay.
> > >
> > > I have two database classes: one for accessing the office, one for > > accessing
> > > the main server. The database classes expose simple functions of > > > connecting, updating and reading from the databases.
> > >
> > > I have a class that operates the synchronization - imports tables in
the
> > > correct order and performs various checks on the data.
> > >
> > > I have a program that calls the synchronization class
sequentially for
> > each
> > > office.
> > >
> > > It takes about 2 minutes per office, or about three hours to complete.
> > I'd
> > > like to run this program hourly, so I want to get the total run time > down.
> > >
> > > I've tried changing the program that calls the synchronization class to
> > > start five threads, and keep five running. The problem I run
into is
> that
> > > the office database class appears to get shared between
threads - I get
> > the
> > > same results back from what should be separate offices running

in > separate
> > > threads.
> > >
> > > How can I set it up so that each thread is entirely separate

from the
> > other
> > > threads, including any support classes called by those threads?
> > >
> > >
> >
> >
>
>



Nov 20 '05 #7

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

Similar topics

15
1645
by: chahnaz.ourzikene | last post by:
Hi all, This is the first i post in this newsgroup, i hope my english is not too bad... Let's get straight to the point ! I have a little probleme using threads in my little training example : I wish to create two threads in my application, one thread (the subject) will increment a variable, and another thread (the controller) will print a message saying "i am waiting..." or someting like that, until the counter of the first thread...
5
3102
by: Sinan Nalkaya | last post by:
hello, i need a function like that, wait 5 seconds: (during wait) do the function but function waits for keyboard input so if you dont enter any it waits forever. i tried time.sleep() but when i used time.sleep in while, the function in while never executed. then i found something about Timer but couldnt realize any algorithm in my mind.
10
1689
by: HK | last post by:
With VB.NET 2005, and a Windows Form, running on a dual CPU box, I need to take a recordset (e.g. 100,000 records) and spawn a thread to handle an internet XML transaction routine for each of the records. This is a nice use of threading because those internet requests are going against 3rd party servers that often have 1 second latency problems and so handling them with multiple threads is the fastest way to get through all the records in...
0
2478
by: hynek.cihlar | last post by:
A strange behaviour thatI found in ASP.NET 2.0. I am trying to issue a callback request (handled by ICallbackEventHandler and RaiseCallbackEvent) and a regular GET request in the client browser and handle them at the same time - in parallel. The funny thing is that the behaviour of the implementation I created depends on the existence of Global.asax in the Web application. Here is the source of the page that handles the regular GET...
9
3269
by: esakal | last post by:
Hello, I'm programming an application based on CAB infrastructure in the client side (c# .net 2005) Since my application must be sequencally, i wrote all the code in the UI thread. my problem occurs when i try to show a progress bar. The screen freezes. I know i'm not the first one to ask about it. but i'm looking
3
9718
by: Ronald S. Cook | last post by:
In my Win app, I'm needing to load a media file into my Windows Media Player control, and THEN read an attribute from the file. The thing is, the file has to be playing for a split second before the attribute can be read. I can have wmpPlayer.URL = @"D:\Web\FWT\TestFile.wma"; in my form load event and then a button on the form to get the value I need... label1.Text = wmpPlayer.currentMedia.getItemInfo("Abstract");
5
2028
by: bean330 | last post by:
Hey, I'm somewhat new to C# and I need a little help, please! I'm selecting a bunch of records, setting properties on a COM executable and then calling a method on that executable to run. I want to run the executable in separate threads because they can be long-running and it would be optimal for us to run a bunch simultaneously. I've got that part working - it's pretty easy in C#. What I'm having a hard time with is managing the...
0
1555
by: Ling | last post by:
I am using boost.python to wrap C++ function which includes directmusic libraries to simply play the midi, but lots of linkage errors "error LNK2001: unresolved external symbol". I wonder if it is possible to work with DirectX - directmusic libs. Are there any ways to wrap it? *********************compilation errors ************************* msvc.link.dll bin\msvc-7.1\debug\threading-multi\playmusic.pyd bin \msvc-7.1\debu...
3
12778
by: dedalusenator | last post by:
Hello Folks, My first posting here and I am a stuck in figuring out the exact way to update a global variable from within a function that doesnt return any value (because the function is a target of the thread and I dont know how exactly return would work in such a case). I am sure I am missing something very fundamental here. The essential pieces of my code that cause the problem would be something like this:...
3
2894
by: Michael Schöller | last post by:
Hello, First of all english is not my natural language so please fogive me some bad mistakes in gramatic and use of some vocables :). I have a great problem here. Well I will not use it anymore but I want to know why it is as it is ^^. I tried with .NET3.0 but I think it will be the same with 2.0 and 3.5. MSDTC is configured and working.
0
8913
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8761
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9280
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6016
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.