473,583 Members | 3,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Threadin g.Timer and Crystal Reports

I've got a background service running that needs to check a database
periodically and print reports whenever it finds that the data has changed.

I've built a class library that scans the database for the changes, and then
generates a report using the VS.NET 2003 version of Crystal Reports, and
prints the report. It works just fine when I use it in a single threaded
environment.

However, when I build an application that uses a System.Threadin g.Timer
object to run this method on a set schedule, anytime I try to work with the
report objects, the thread just hangs and never comes back

Is there some threading issue in Crystal Reports that anyone knows about, or
better yet, is there some way in C# to get back on the main execution thread
so that I can work with the reports there, avoiding this problem? Remember,
this is all running in a service or a console app, so I don't have a windows
form I can call Invoke or BeginInvoke on.

Thanks!

Ryan Gregg
Nov 16 '05 #1
4 2959
Two things to check:

1. Make sure you have the [STAThread] attribute above your main. Crystal
ultimately calls into COM objects, and they may require single-threaded
apartment model.

2. If you're running as a service when the crashes happen, try allowing the
service to interact with the desktop. (it's possible it needs graphic dc's)

"Ryan Gregg" <rg****@wheatla ndsystems.com> wrote in message
news:ez******** ******@TK2MSFTN GP10.phx.gbl...
I've got a background service running that needs to check a database
periodically and print reports whenever it finds that the data has changed.
I've built a class library that scans the database for the changes, and then generates a report using the VS.NET 2003 version of Crystal Reports, and
prints the report. It works just fine when I use it in a single threaded
environment.

However, when I build an application that uses a System.Threadin g.Timer
object to run this method on a set schedule, anytime I try to work with the report objects, the thread just hangs and never comes back

Is there some threading issue in Crystal Reports that anyone knows about, or better yet, is there some way in C# to get back on the main execution thread so that I can work with the reports there, avoiding this problem? Remember, this is all running in a service or a console app, so I don't have a windows form I can call Invoke or BeginInvoke on.

Thanks!

Ryan Gregg

Nov 16 '05 #2
Thanks for your reply Philip. However, I've got the STAThread attribute on
my main method. I'm actually running the service right now (in order to
debug it) through a console application. I wrote a class library that does
all the service actions, and then I have two other projects that I can use
to run it, either as a console window or as a Win32 service. It behaves the
same way regardless of how I run it.

I created a 3 test cases using a Console program and different threading
aspects, and it never has any problems there. However, it always dies in my
real application.

Any other ideas?

Thanks again.

Ryan Gregg
"Philip Rieck" <st***@mckraken .com> wrote in message
news:e3******** ******@TK2MSFTN GP09.phx.gbl...
Two things to check:

1. Make sure you have the [STAThread] attribute above your main. Crystal
ultimately calls into COM objects, and they may require single-threaded
apartment model.

2. If you're running as a service when the crashes happen, try allowing the service to interact with the desktop. (it's possible it needs graphic dc's)
"Ryan Gregg" <rg****@wheatla ndsystems.com> wrote in message
news:ez******** ******@TK2MSFTN GP10.phx.gbl...
I've got a background service running that needs to check a database
periodically and print reports whenever it finds that the data has changed.

I've built a class library that scans the database for the changes, and

then
generates a report using the VS.NET 2003 version of Crystal Reports, and
prints the report. It works just fine when I use it in a single threaded environment.

However, when I build an application that uses a System.Threadin g.Timer
object to run this method on a set schedule, anytime I try to work with

the
report objects, the thread just hangs and never comes back

Is there some threading issue in Crystal Reports that anyone knows

about, or
better yet, is there some way in C# to get back on the main execution

thread
so that I can work with the reports there, avoiding this problem?

Remember,
this is all running in a service or a console app, so I don't have a

windows
form I can call Invoke or BeginInvoke on.

Thanks!

Ryan Gregg


Nov 16 '05 #3
I wish I had more ideas for you. If you have a simple repro case, feel free
to email it to me and I'll take a look. Otherwise, I'm of no help to you at
the moment -- Crystal is just not my forte. (in fact, I avoid it if I can).
Good luck!
"Ryan Gregg" <rg****@wheatla ndsystems.com> wrote in message
news:OZ******** ******@TK2MSFTN GP12.phx.gbl...
Thanks for your reply Philip. However, I've got the STAThread attribute on my main method. I'm actually running the service right now (in order to
debug it) through a console application. I wrote a class library that does all the service actions, and then I have two other projects that I can use
to run it, either as a console window or as a Win32 service. It behaves the same way regardless of how I run it.

I created a 3 test cases using a Console program and different threading
aspects, and it never has any problems there. However, it always dies in my real application.

Any other ideas?

Thanks again.

Ryan Gregg
"Philip Rieck" <st***@mckraken .com> wrote in message
news:e3******** ******@TK2MSFTN GP09.phx.gbl...
Two things to check:

1. Make sure you have the [STAThread] attribute above your main. Crystal
ultimately calls into COM objects, and they may require single-threaded
apartment model.

2. If you're running as a service when the crashes happen, try allowing

the
service to interact with the desktop. (it's possible it needs graphic

dc's)

"Ryan Gregg" <rg****@wheatla ndsystems.com> wrote in message
news:ez******** ******@TK2MSFTN GP10.phx.gbl...
I've got a background service running that needs to check a database
periodically and print reports whenever it finds that the data has

changed.

I've built a class library that scans the database for the changes, and
then
generates a report using the VS.NET 2003 version of Crystal Reports,
and prints the report. It works just fine when I use it in a single

threaded environment.

However, when I build an application that uses a System.Threadin g.Timer object to run this method on a set schedule, anytime I try to work

with the
report objects, the thread just hangs and never comes back

Is there some threading issue in Crystal Reports that anyone knows

about,
or
better yet, is there some way in C# to get back on the main execution

thread
so that I can work with the reports there, avoiding this problem?

Remember,
this is all running in a service or a console app, so I don't have a

windows
form I can call Invoke or BeginInvoke on.

Thanks!

Ryan Gregg



Nov 16 '05 #4
I know what you mean :-) Unforutnately I haven't been able to reproduce the
problem in a simple fashion. In fact, the project I've been working with
appears to work just fine on another development machine I have. I'm now
wondering if it is some sort of side effect of having CrystalReports 8.5
installed.

Thanks again Philip!

Ryan Gregg

"Philip Rieck" <st***@mckraken .com> wrote in message
news:eM******** ******@TK2MSFTN GP09.phx.gbl...
I wish I had more ideas for you. If you have a simple repro case, feel free to email it to me and I'll take a look. Otherwise, I'm of no help to you at the moment -- Crystal is just not my forte. (in fact, I avoid it if I can). Good luck!
"Ryan Gregg" <rg****@wheatla ndsystems.com> wrote in message
news:OZ******** ******@TK2MSFTN GP12.phx.gbl...
Thanks for your reply Philip. However, I've got the STAThread attribute on
my main method. I'm actually running the service right now (in order to
debug it) through a console application. I wrote a class library that

does
all the service actions, and then I have two other projects that I can use
to run it, either as a console window or as a Win32 service. It behaves

the
same way regardless of how I run it.

I created a 3 test cases using a Console program and different threading
aspects, and it never has any problems there. However, it always dies in my
real application.

Any other ideas?

Thanks again.

Ryan Gregg
"Philip Rieck" <st***@mckraken .com> wrote in message
news:e3******** ******@TK2MSFTN GP09.phx.gbl...
Two things to check:

1. Make sure you have the [STAThread] attribute above your main.

Crystal ultimately calls into COM objects, and they may require single-threaded apartment model.

2. If you're running as a service when the crashes happen, try allowing the
service to interact with the desktop. (it's possible it needs graphic

dc's)

"Ryan Gregg" <rg****@wheatla ndsystems.com> wrote in message
news:ez******** ******@TK2MSFTN GP10.phx.gbl...
> I've got a background service running that needs to check a database
> periodically and print reports whenever it finds that the data has
changed.
>
> I've built a class library that scans the database for the changes, and then
> generates a report using the VS.NET 2003 version of Crystal Reports, and > prints the report. It works just fine when I use it in a single

threaded
> environment.
>
> However, when I build an application that uses a System.Threadin g.Timer > object to run this method on a set schedule, anytime I try to work with the
> report objects, the thread just hangs and never comes back
>
> Is there some threading issue in Crystal Reports that anyone knows

about,
or
> better yet, is there some way in C# to get back on the main

execution thread
> so that I can work with the reports there, avoiding this problem?
Remember,
> this is all running in a service or a console app, so I don't have a
windows
> form I can call Invoke or BeginInvoke on.
>
> Thanks!
>
> Ryan Gregg
>
>



Nov 16 '05 #5

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

Similar topics

0
1904
by: K Karthik | last post by:
Hi; I am using a Crystal Report Viewer to display Crystal Reports(rpt). I want to refresh these reports based on a timer. Inside the timer function i am calling CrystalReportViewer.RefreshReport() But this does not work.. Please help.
3
5586
by: ELO | last post by:
Hi all Every week, I need to get two files on a remote server. I have developped a C# Windows Service with two System.Threading.Timer to do this task For the first one, the delay (TimeSpan dueTime) is always set to 6 days, 23 hours, 59 minutes, .. Some weeks ?!?, the timer restarts immediately after its execution (and loop indefinitely)....
4
4046
by: Hagay Lupesko | last post by:
Hi, I've encountered a strange phenomena which appears to me as a bug: I have an engine that uses a System.Threading.Timer to invoke a delegate every X minutes. The code looks something like this: TimerCallback callBack = new TimerCallback(Run); // run is obviously a method
1
7703
by: Can Balioglu | last post by:
Hi, I don't know if it's already known but I found a bug in System.Timers.Timer class. The 'Interval' property accepts a double which specifies the interval between two 'Elapsed' events. The 'Start' method just sets the 'Enabled' property to true. And the problem lies in the 'Enabled' property. It casts the interval value to an integer...
1
2275
by: Tom | last post by:
I've googled, and read, and stripped out code, and rewritten code, and still can't get a System.Threading.Timer to work. (I hereby publicly admit that I'm a failure here...) Could someone please take a quick look at this and tell me where I'm going wrong? My actual use is more complex, but when I couldn't get that to work I created a new...
6
2851
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a TimerState object similar to the example in the System.Threading.Timer documentation. The method which handles the timer events, among other things,...
2
13177
by: linesh.gajera | last post by:
Hi Guys, I am creating a Windows service that call a routine at given interval. Once routine is complete, windows service should wait for 5 minutes and then call the routine again. I was using System.Timers.Timer but i had to remove it because of known bug(842739). Now i am using System.Threading.Timer. It executes routine fine but the...
4
14386
by: Lauren Quantrell | last post by:
I have just put together a vb.net app and now need to provide it to users. This application needs to run the code in a sub every 60 seconds from a Windows Service application. I have the functionality of the sub working fine but I cannot figure out how to run the timer. The sub DoSomethingHere() needs to run every 60 seconds. It doesn't...
4
5711
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, i have a main thread an another worker thread. The main Thread creates another thread and waits for the threads signal to continue the main thread. Everything works inside a ModalDialog and everyting is secured by Invoke/BeginInvoke, and synchronisation primitves like WaitHandles, Evetns, Semaphores, etc... All works good and with no...
0
7893
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...
0
8317
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...
1
7928
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...
1
5695
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...
0
5369
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...
0
3813
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...
0
3839
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1422
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1151
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...

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.