473,698 Members | 2,556 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 1343
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
1638
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
1685
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
2473
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
3267
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
9717
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
2027
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
1554
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
12777
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
2890
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
8683
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
9170
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
9031
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...
0
7739
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 project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5862
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();...
0
4371
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
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.