Saturday, March 31, 2012
Sending/Receiving data from remote app
Anyone done something similar?how is the remote app usually contacted. Does it send back a httpresponse. or is it some service that returns a stream of characters.
HTTPResponse object if it's replying in http
probably SOCKETS if it's returning data ( like telnet)
I have no experience doing this - but hope that points you in right direction
Separate Project DLLs
Apologies for this simple question. Would be grateful if you share your
opinion on this.
I've written a web application, compiling all classes into one project
DLL. Now I wonder if there are performance / resource advantages if I
compile some classes into separate DLLs and reference them instead. Any
articles, information on this? Advantages, Di
down the application if it has to reference a DLL?
Thanks very much for your help & efforts!
MartinPerformance isn't a factor...Di
which might make it harder to maintain (assuming you are shipping a product,
which you likely aren't). Advantages? Better organization, reuse, less
bloat...
There's really no reason not to...but you shouldn't just do it for the sake
of it...hopefully there's some reasoning behind why they don't belong
together...
Karl
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
<theintrepidfox@.hotmail.com> wrote in message
news:1112238300.593113.237330@.f14g2000cwb.googlegroups.com...
> Dear Group
> Apologies for this simple question. Would be grateful if you share your
> opinion on this.
> I've written a web application, compiling all classes into one project
> DLL. Now I wonder if there are performance / resource advantages if I
> compile some classes into separate DLLs and reference them instead. Any
> articles, information on this? Advantages, Di
> down the application if it has to reference a DLL?
> Thanks very much for your help & efforts!
> Martin
>
It is not a matter of performance. It is a matter of your system design. For
example, if you organize your application in presentation, business and data
access layers, you might have all forms in one project, business classes in
another project and data access classes in another project. 3 projects, 3
dlls.
Eliyahu
<theintrepidfox@.hotmail.com> wrote in message
news:1112238300.593113.237330@.f14g2000cwb.googlegroups.com...
> Dear Group
> Apologies for this simple question. Would be grateful if you share your
> opinion on this.
> I've written a web application, compiling all classes into one project
> DLL. Now I wonder if there are performance / resource advantages if I
> compile some classes into separate DLLs and reference them instead. Any
> articles, information on this? Advantages, Di
> down the application if it has to reference a DLL?
> Thanks very much for your help & efforts!
> Martin
>
Separate Project DLLs
Apologies for this simple question. Would be grateful if you share your
opinion on this.
I've written a web application, compiling all classes into one project
DLL. Now I wonder if there are performance / resource advantages if I
compile some classes into separate DLLs and reference them instead. Any
articles, information on this? Advantages, Disadvantages? Will it slow
down the application if it has to reference a DLL?
Thanks very much for your help & efforts!
MartinPerformance isn't a factor...Disadvantage? You have 2+ dlls floating around
which might make it harder to maintain (assuming you are shipping a product,
which you likely aren't). Advantages? Better organization, reuse, less
bloat...
There's really no reason not to...but you shouldn't just do it for the sake
of it...hopefully there's some reasoning behind why they don't belong
together...
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
<theintrepidfox@.hotmail.com> wrote in message
news:1112238300.593113.237330@.f14g2000cwb.googlegr oups.com...
> Dear Group
> Apologies for this simple question. Would be grateful if you share your
> opinion on this.
> I've written a web application, compiling all classes into one project
> DLL. Now I wonder if there are performance / resource advantages if I
> compile some classes into separate DLLs and reference them instead. Any
> articles, information on this? Advantages, Disadvantages? Will it slow
> down the application if it has to reference a DLL?
> Thanks very much for your help & efforts!
> Martin
It is not a matter of performance. It is a matter of your system design. For
example, if you organize your application in presentation, business and data
access layers, you might have all forms in one project, business classes in
another project and data access classes in another project. 3 projects, 3
dlls.
Eliyahu
<theintrepidfox@.hotmail.com> wrote in message
news:1112238300.593113.237330@.f14g2000cwb.googlegr oups.com...
> Dear Group
> Apologies for this simple question. Would be grateful if you share your
> opinion on this.
> I've written a web application, compiling all classes into one project
> DLL. Now I wonder if there are performance / resource advantages if I
> compile some classes into separate DLLs and reference them instead. Any
> articles, information on this? Advantages, Disadvantages? Will it slow
> down the application if it has to reference a DLL?
> Thanks very much for your help & efforts!
> Martin
Thursday, March 29, 2012
Separate VB app to talk back to a Web Service
data transformation and puts the data into a special format that
another application uses. That data is in a file.
This other application continuously polls a folder for these data
files and processes them. It eventually creates a PDF out of the
data with a unique file name.
Web service needs to know when this other application is done
processing this data so I can send a URL of the created PDF back to
customer.
What would be the best way to do this? I don't want to sit there and
poll a folder for the output file, as we may have up to 40,000
requests / day.look at windows workflow or sqlserver broker services.
-- bruce (sqlwork.com)
"Larry Bud" wrote:
> Customer sends XML data to our Web Service. Web Service does some
> data transformation and puts the data into a special format that
> another application uses. That data is in a file.
> This other application continuously polls a folder for these data
> files and processes them. It eventually creates a PDF out of the
> data with a unique file name.
> Web service needs to know when this other application is done
> processing this data so I can send a URL of the created PDF back to
> customer.
> What would be the best way to do this? I don't want to sit there and
> poll a folder for the output file, as we may have up to 40,000
> requests / day.
>
In addition to Bruce's suggestion - what I have done in the past is have a
method that allows the client to check a DB value against each created file
using the number they are given on submission. For me it was word files
converted to PDF and a succesful creation triggered a DB update and then
stored the output URL - cleaning up after a 24 hour period. Because its
only a small request with a single return value it was cheap for the client
to check the webservice for a success flag and then get the URL. This
didn't massively impact throughput and could be hosted on a different app
server entirely.
Regards
John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"bruce barker" <brucebarker@.discussions.microsoft.com> wrote in message
news:7BFFAD45-86AA-48B5-AFB1-42DB21056491@.microsoft.com...
> look at windows workflow or sqlserver broker services.
> -- bruce (sqlwork.com)
>
> "Larry Bud" wrote:
>
On Feb 11, 4:37=A0pm, "John Timney \(MVP\)"
<xyz_j...@.timney.eclipse.co.uk> wrote:
> In addition to Bruce's suggestion - what I have done in the past is have a=[/color
]
> method that allows the client to check a DB value against each created fil=[/color
]
e
> using the number they are given on submission. =A0For me it was word files=[/color
]
> converted to PDF and a succesful creation triggered a DB update and then
> stored the output URL - cleaning up after a 24 hour period. =A0Because its=[/color
]
> only a small request with a single return value it was cheap for the clien=[/color
]
t
> to check the webservice for a success flag and then get the URL. =A0This
> didn't massively impact throughput and could be hosted on a different app
> server entirely.
>
Wouldn't you have to keep hitting the database to see if the file was
created successfully?
Yes, but it doesn't have to be the same database, or even the same database
server!
Regards
John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Larry Bud" <larrybud2002@.yahoo.com> wrote in message
news:e2449b23-38af-4876-88c5-df0f10f77278@.s8g2000prg.googlegroups.com...
On Feb 11, 4:37 pm, "John Timney \(MVP\)"
<xyz_j...@.timney.eclipse.co.uk> wrote:
> In addition to Bruce's suggestion - what I have done in the past is have a
> method that allows the client to check a DB value against each created
> file
> using the number they are given on submission. For me it was word files
> converted to PDF and a succesful creation triggered a DB update and then
> stored the output URL - cleaning up after a 24 hour period. Because its
> only a small request with a single return value it was cheap for the
> client
> to check the webservice for a success flag and then get the URL. This
> didn't massively impact throughput and could be hosted on a different app
> server entirely.
>
Wouldn't you have to keep hitting the database to see if the file was
created successfully?
Separate Webserver and SQL Server -- error when connecting asp.net
I would like to ask for some help regarding separating the asp.net
webserver and the sql server.
I have created an asp.net application for a certain company. Initially,
we installed both the iis and sql server in a single machine. Not too
long ago, the machine had some hardware problems, and management has
decided to purchase new servers, for both asp.net and sql server.
Once we installed my webapp on the first server and the sql server on
another, we have encountered some errors with it. Basically, the
exception that keeps on saying was:
"SQL Server database does not exist or access denied."
Tried creating a windows account for the webapp to use to connect and
configure it to the sql server, but it does not work.
Tried also connecting with the database using a SQL Server account, but
to no avail.
Please help! I would really appreciate it!!
Regards,
Ann MarinasHi, Wessel!
Thank you for your reply.
I've changed my connectionstring property after the database was
transfered to another server and it has got all the correct values, but
still no avail.
Thanks again for helping me out! Really do appreciate it!
Cheers,
Ann
Wessel Troost wrote:
> An ASP.NET application typically connects to the database through a
> System.Data.SqlClient.SqlConnection object.
> To change the SQL server, you need to find all SqlConnection objects and
> update their ConnectionString property to point to the new database
> server.
> Greetings,
> Wessel
> --Original Message--
> From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
> Posted At: Sunday, April 10, 2005 12:11 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: Separate Webserver and SQL Server -- error when connecting
> asp.net app to a database
> Subject: Separate Webserver and SQL Server -- error when connecting
> asp.net app to a database
> Hi all,
> I would like to ask for some help regarding separating the asp.net
> webserver and the sql server.
> I have created an asp.net application for a certain company. Initially,
> we installed both the iis and sql server in a single machine. Not too
> long ago, the machine had some hardware problems, and management has
> decided to purchase new servers, for both asp.net and sql server.
> Once we installed my webapp on the first server and the sql server on
> another, we have encountered some errors with it. Basically, the
> exception that keeps on saying was:
> "SQL Server database does not exist or access denied."
> Tried creating a windows account for the webapp to use to connect and
> configure it to the sql server, but it does not work.
> Tried also connecting with the database using a SQL Server account, but
> to no avail.
> Please help! I would really appreciate it!!
>
> Regards,
> Ann Marinas
>
Hi, Mark!
Thank you for helping me out.
1) I am using System.Data.SqlClient for my data access.
2) I have changed the connection string which was located in my
web.config file when we separated the webserver to the sql db server
3) The authenticatio is set to Mixed mode -- SQL Server and Windows
Authentication
4) On the Webserver, the Query Analyzer is not installed on the
webserver. However if I am going to access the query analyzer, I have to
access the sql server itself.
Thanks again!
Mark Rae wrote:
> "Ann Marinas" <ka_marinas@.xtra.co.nz> wrote in message
> news:O8EQVObPFHA.2604@.TK2MSFTNGP10.phx.gbl...
>
>
> 1) Are you using the native .NET data provider, OleDb or (surely not!) ODB
C?
> 2) What ConnectionString are you using?
> 3) When you installed SQL Server, what authentication mode did you choose
> (SQL Server, Windows or mixed)?
> 4) On the SQL Server machine, launch SQL Query Analyzer (NOT ENTERPRISE
> MANAGER!) and try to log in using the UserID and password from the
> ConnectionString in 2) above - can you? If so, can you drop the database
> dropdown and select the database from the ConnectionString in 2) above? If
> so, run SELECT * FROM sysobjects - what do you see?
>
Separate Webserver and SQL Server -- error when connecting asp.netapp to a database
I would like to ask for some help regarding separating the asp.net
webserver and the sql server.
I have created an asp.net application for a certain company. Initially,
we installed both the iis and sql server in a single machine. Not too
long ago, the machine had some hardware problems, and management has
decided to purchase new servers, for both asp.net and sql server.
Once we installed my webapp on the first server and the sql server on
another, we have encountered some errors with it. Basically, the
exception that keeps on saying was:
"SQL Server database does not exist or access denied."
Tried creating a windows account for the webapp to use to connect and
configure it to the sql server, but it does not work.
Tried also connecting with the database using a SQL Server account, but
to no avail.
Please help! I would really appreciate it!!
Regards,
Ann MarinasAn ASP.NET application typically connects to the database through a
System.Data.SqlClient.SqlConnection object.
To change the SQL server, you need to find all SqlConnection objects and
update their ConnectionString property to point to the new database
server.
Greetings,
Wessel
--Original Message--
From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
Posted At: Sunday, April 10, 2005 12:11 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: Separate Webserver and SQL Server -- error when connecting
asp.net app to a database
Subject: Separate Webserver and SQL Server -- error when connecting
asp.net app to a database
Hi all,
I would like to ask for some help regarding separating the asp.net
webserver and the sql server.
I have created an asp.net application for a certain company. Initially,
we installed both the iis and sql server in a single machine. Not too
long ago, the machine had some hardware problems, and management has
decided to purchase new servers, for both asp.net and sql server.
Once we installed my webapp on the first server and the sql server on
another, we have encountered some errors with it. Basically, the
exception that keeps on saying was:
"SQL Server database does not exist or access denied."
Tried creating a windows account for the webapp to use to connect and
configure it to the sql server, but it does not work.
Tried also connecting with the database using a SQL Server account, but
to no avail.
Please help! I would really appreciate it!!
Regards,
Ann Marinas
"Ann Marinas" <ka_marinas@.xtra.co.nz> wrote in message
news:O8EQVObPFHA.2604@.TK2MSFTNGP10.phx.gbl...
> Please help! I would really appreciate it!!
1) Are you using the native .NET data provider, OleDb or (surely not!) ODBC?
2) What ConnectionString are you using?
3) When you installed SQL Server, what authentication mode did you choose
(SQL Server, Windows or mixed)?
4) On the SQL Server machine, launch SQL Query Analyzer (NOT ENTERPRISE
MANAGER!) and try to log in using the UserID and password from the
ConnectionString in 2) above - can you? If so, can you drop the database
dropdown and select the database from the ConnectionString in 2) above? If
so, run SELECT * FROM sysobjects - what do you see?
Hi, Wessel!
Thank you for your reply.
I've changed my connectionstring property after the database was
transfered to another server and it has got all the correct values, but
still no avail.
Thanks again for helping me out! Really do appreciate it!
Cheers,
Ann
Wessel Troost wrote:
> An ASP.NET application typically connects to the database through a
> System.Data.SqlClient.SqlConnection object.
> To change the SQL server, you need to find all SqlConnection objects and
> update their ConnectionString property to point to the new database
> server.
> Greetings,
> Wessel
> --Original Message--
> From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
> Posted At: Sunday, April 10, 2005 12:11 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: Separate Webserver and SQL Server -- error when connecting
> asp.net app to a database
> Subject: Separate Webserver and SQL Server -- error when connecting
> asp.net app to a database
> Hi all,
> I would like to ask for some help regarding separating the asp.net
> webserver and the sql server.
> I have created an asp.net application for a certain company. Initially,
> we installed both the iis and sql server in a single machine. Not too
> long ago, the machine had some hardware problems, and management has
> decided to purchase new servers, for both asp.net and sql server.
> Once we installed my webapp on the first server and the sql server on
> another, we have encountered some errors with it. Basically, the
> exception that keeps on saying was:
> "SQL Server database does not exist or access denied."
> Tried creating a windows account for the webapp to use to connect and
> configure it to the sql server, but it does not work.
> Tried also connecting with the database using a SQL Server account, but
> to no avail.
> Please help! I would really appreciate it!!
>
> Regards,
> Ann Marinas
Hi, Mark!
Thank you for helping me out.
1) I am using System.Data.SqlClient for my data access.
2) I have changed the connection string which was located in my
web.config file when we separated the webserver to the sql db server
3) The authenticatio is set to Mixed mode -- SQL Server and Windows
Authentication
4) On the Webserver, the Query Analyzer is not installed on the
webserver. However if I am going to access the query analyzer, I have to
access the sql server itself.
Thanks again!
Mark Rae wrote:
> "Ann Marinas" <ka_marinas@.xtra.co.nz> wrote in message
> news:O8EQVObPFHA.2604@.TK2MSFTNGP10.phx.gbl...
>
>>Please help! I would really appreciate it!!
>
> 1) Are you using the native .NET data provider, OleDb or (surely not!) ODBC?
> 2) What ConnectionString are you using?
> 3) When you installed SQL Server, what authentication mode did you choose
> (SQL Server, Windows or mixed)?
> 4) On the SQL Server machine, launch SQL Query Analyzer (NOT ENTERPRISE
> MANAGER!) and try to log in using the UserID and password from the
> ConnectionString in 2) above - can you? If so, can you drop the database
> dropdown and select the database from the ConnectionString in 2) above? If
> so, run SELECT * FROM sysobjects - what do you see?
>
- Post the connection string, we might be able to help.
- "telnet sqlserver 1433" to see if you can reach the SQL server. 1433
is the default SQL server port.
- Check the firewall settings on the SQL Server.
- Check if the SQL Server user has a default database, and if the user
is valid in that database.
Greetings,
Wessel
--Original Message--
From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
Posted At: Sunday, April 10, 2005 12:55 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: Separate Webserver and SQL Server -- error when connecting
asp.net app to a database
Subject: Re: Separate Webserver and SQL Server -- error when connecting
asp.net app to a database
Hi, Wessel!
Thank you for your reply.
I've changed my connectionstring property after the database was
transfered to another server and it has got all the correct values, but
still no avail.
Thanks again for helping me out! Really do appreciate it!
Cheers,
Ann
Wessel Troost wrote:
> An ASP.NET application typically connects to the database through a
> System.Data.SqlClient.SqlConnection object.
> To change the SQL server, you need to find all SqlConnection objects
and
> update their ConnectionString property to point to the new database
> server.
> Greetings,
> Wessel
> --Original Message--
> From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
> Posted At: Sunday, April 10, 2005 12:11 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: Separate Webserver and SQL Server -- error when
connecting
> asp.net app to a database
> Subject: Separate Webserver and SQL Server -- error when connecting
> asp.net app to a database
> Hi all,
> I would like to ask for some help regarding separating the asp.net
> webserver and the sql server.
> I have created an asp.net application for a certain company.
Initially,
> we installed both the iis and sql server in a single machine. Not too
> long ago, the machine had some hardware problems, and management has
> decided to purchase new servers, for both asp.net and sql server.
> Once we installed my webapp on the first server and the sql server on
> another, we have encountered some errors with it. Basically, the
> exception that keeps on saying was:
> "SQL Server database does not exist or access denied."
> Tried creating a windows account for the webapp to use to connect and
> configure it to the sql server, but it does not work.
> Tried also connecting with the database using a SQL Server account,
but
> to no avail.
> Please help! I would really appreciate it!!
>
> Regards,
> Ann Marinas
"Ann Marinas" <ka_marinas@.xtra.co.nz> wrote in message
news:erPYsrbPFHA.3336@.TK2MSFTNGP09.phx.gbl...
Ann,
> 1) I am using System.Data.SqlClient for my data access.
That's a good thing.
> 2) I have changed the connection string which was located in my web.config
> file when we separated the webserver to the sql db server
I'm sure you have but, if we're going to help you, you're going to have to
tell us what the ConnectionString is... :-)
> 3) The authenticatio is set to Mixed mode -- SQL Server and Windows
> Authentication
Even easier.
> 4) On the Webserver, the Query Analyzer is not installed on the webserver.
> However if I am going to access the query analyzer, I have to access the
> sql server itself.
No - just use any machine which can "see" the SQL Server and which has the
SQL Client Tools installed.
Ann,
You are getting an error in accessing database. This means that server
connections is ok, just database is not accessible. Most likely you have to
have another look into permissions for the login you are connecting under
for the database you are connecting to. Or make sure the database name is
correct.
Eliyahu
"Ann Marinas" <ka_marinas@.xtra.co.nz> wrote in message
news:O8EQVObPFHA.2604@.TK2MSFTNGP10.phx.gbl...
> Hi all,
> I would like to ask for some help regarding separating the asp.net
> webserver and the sql server.
> I have created an asp.net application for a certain company. Initially,
> we installed both the iis and sql server in a single machine. Not too
> long ago, the machine had some hardware problems, and management has
> decided to purchase new servers, for both asp.net and sql server.
> Once we installed my webapp on the first server and the sql server on
> another, we have encountered some errors with it. Basically, the
> exception that keeps on saying was:
> "SQL Server database does not exist or access denied."
> Tried creating a windows account for the webapp to use to connect and
> configure it to the sql server, but it does not work.
> Tried also connecting with the database using a SQL Server account, but
> to no avail.
> Please help! I would really appreciate it!!
>
> Regards,
> Ann Marinas
the connection string is:
Data Provider=myDB; Initial Catalog=myDBName; Integrated Securit=SSPI
tried doing the telnet, and it says:
Connecting To database...Could not open a connection to host on port 1433 :
Connect failed
Really do appreciate your help!
"Wessel Troost" wrote:
> - Post the connection string, we might be able to help.
> - "telnet sqlserver 1433" to see if you can reach the SQL server. 1433
> is the default SQL server port.
> - Check the firewall settings on the SQL Server.
> - Check if the SQL Server user has a default database, and if the user
> is valid in that database.
> Greetings,
> Wessel
> --Original Message--
> From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
> Posted At: Sunday, April 10, 2005 12:55 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: Separate Webserver and SQL Server -- error when connecting
> asp.net app to a database
> Subject: Re: Separate Webserver and SQL Server -- error when connecting
> asp.net app to a database
> Hi, Wessel!
> Thank you for your reply.
> I've changed my connectionstring property after the database was
> transfered to another server and it has got all the correct values, but
> still no avail.
> Thanks again for helping me out! Really do appreciate it!
> Cheers,
> Ann
> Wessel Troost wrote:
> > An ASP.NET application typically connects to the database through a
> > System.Data.SqlClient.SqlConnection object.
> > To change the SQL server, you need to find all SqlConnection objects
> and
> > update their ConnectionString property to point to the new database
> > server.
> > Greetings,
> > Wessel
> > --Original Message--
> > From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
> > Posted At: Sunday, April 10, 2005 12:11 PM
> > Posted To: microsoft.public.dotnet.framework.aspnet
> > Conversation: Separate Webserver and SQL Server -- error when
> connecting
> > asp.net app to a database
> > Subject: Separate Webserver and SQL Server -- error when connecting
> > asp.net app to a database
> > Hi all,
> > I would like to ask for some help regarding separating the asp.net
> > webserver and the sql server.
> > I have created an asp.net application for a certain company.
> Initially,
> > we installed both the iis and sql server in a single machine. Not too
> > long ago, the machine had some hardware problems, and management has
> > decided to purchase new servers, for both asp.net and sql server.
> > Once we installed my webapp on the first server and the sql server on
> > another, we have encountered some errors with it. Basically, the
> > exception that keeps on saying was:
> > "SQL Server database does not exist or access denied."
> > Tried creating a windows account for the webapp to use to connect and
> > configure it to the sql server, but it does not work.
> > Tried also connecting with the database using a SQL Server account,
> but
> > to no avail.
> > Please help! I would really appreciate it!!
> > Regards,
> > Ann Marinas
>
Hi, Eliyahu!
I've checked the name of the database and the windows user access name that
will be used for the database connection. Before I did that, I've double-
checked as well the user account that will be used to impersonate the access
if it has permissions on the SQL Server database, but to no avail.
It keeps on saying that the db is not existing or access is denied -- in
which I could clearly see the database on the database folder.
Thanks for helping me out! Really appreciate it! :)
"Eliyahu Goldin" wrote:
> Ann,
> You are getting an error in accessing database. This means that server
> connections is ok, just database is not accessible. Most likely you have to
> have another look into permissions for the login you are connecting under
> for the database you are connecting to. Or make sure the database name is
> correct.
> Eliyahu
> "Ann Marinas" <ka_marinas@.xtra.co.nz> wrote in message
> news:O8EQVObPFHA.2604@.TK2MSFTNGP10.phx.gbl...
> > Hi all,
> > I would like to ask for some help regarding separating the asp.net
> > webserver and the sql server.
> > I have created an asp.net application for a certain company. Initially,
> > we installed both the iis and sql server in a single machine. Not too
> > long ago, the machine had some hardware problems, and management has
> > decided to purchase new servers, for both asp.net and sql server.
> > Once we installed my webapp on the first server and the sql server on
> > another, we have encountered some errors with it. Basically, the
> > exception that keeps on saying was:
> > "SQL Server database does not exist or access denied."
> > Tried creating a windows account for the webapp to use to connect and
> > configure it to the sql server, but it does not work.
> > Tried also connecting with the database using a SQL Server account, but
> > to no avail.
> > Please help! I would really appreciate it!!
> > Regards,
> > Ann Marinas
>
Hi Ann,
Looks like there's more than one issue. I think a connection string for
SQL server looks like this:
data source=...;user id=...;password=...;initial catalog=...;
The data provider is the driver that serves your database, not the
database.
Below this, on the network layer, there's no chance your connection is
going to work if you can't connect to the database server on port 1433.
Greetings,
Wessel
--Original Message--
From: Ann Marinas [mailto:Ann Marinas@.discussions.microsoft.com]
Posted At: Sunday, April 10, 2005 11:15 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: Separate Webserver and SQL Server -- error when connecting
asp.net app to a database
Subject: Re: Separate Webserver and SQL Server -- error when connecting
asp
the connection string is:
Data Provider=myDB; Initial Catalog=myDBName; Integrated Securit=SSPI
tried doing the telnet, and it says:
Connecting To database...Could not open a connection to host on port
1433 :
Connect failed
Really do appreciate your help!
"Wessel Troost" wrote:
> - Post the connection string, we might be able to help.
> - "telnet sqlserver 1433" to see if you can reach the SQL server. 1433
> is the default SQL server port.
> - Check the firewall settings on the SQL Server.
> - Check if the SQL Server user has a default database, and if the user
> is valid in that database.
> Greetings,
> Wessel
> --Original Message--
> From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
> Posted At: Sunday, April 10, 2005 12:55 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: Separate Webserver and SQL Server -- error when
connecting
> asp.net app to a database
> Subject: Re: Separate Webserver and SQL Server -- error when
connecting
> asp.net app to a database
> Hi, Wessel!
> Thank you for your reply.
> I've changed my connectionstring property after the database was
> transfered to another server and it has got all the correct values,
but
> still no avail.
> Thanks again for helping me out! Really do appreciate it!
> Cheers,
> Ann
> Wessel Troost wrote:
> > An ASP.NET application typically connects to the database through a
> > System.Data.SqlClient.SqlConnection object.
> > To change the SQL server, you need to find all SqlConnection objects
> and
> > update their ConnectionString property to point to the new database
> > server.
> > Greetings,
> > Wessel
> > --Original Message--
> > From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
> > Posted At: Sunday, April 10, 2005 12:11 PM
> > Posted To: microsoft.public.dotnet.framework.aspnet
> > Conversation: Separate Webserver and SQL Server -- error when
> connecting
> > asp.net app to a database
> > Subject: Separate Webserver and SQL Server -- error when connecting
> > asp.net app to a database
> > Hi all,
> > I would like to ask for some help regarding separating the asp.net
> > webserver and the sql server.
> > I have created an asp.net application for a certain company.
> Initially,
> > we installed both the iis and sql server in a single machine. Not
too
> > long ago, the machine had some hardware problems, and management has
> > decided to purchase new servers, for both asp.net and sql server.
> > Once we installed my webapp on the first server and the sql server
on
> > another, we have encountered some errors with it. Basically, the
> > exception that keeps on saying was:
> > "SQL Server database does not exist or access denied."
> > Tried creating a windows account for the webapp to use to connect
and
> > configure it to the sql server, but it does not work.
> > Tried also connecting with the database using a SQL Server account,
> but
> > to no avail.
> > Please help! I would really appreciate it!!
> > Regards,
> > Ann Marinas
http://support.microsoft.com/kb/827422
John Webb
One of my developers had the same problem and I fixed it by changing the
identity with which ASP.NET
process was running that web-application. Add the following section to your
application's web.config file:
<system.web>
<identity impersonate="true" userName="someaccount" password="something"
/>
</system.web
Note that provided windows user account must have granted required
permissions to access the remote database.
I also tried something else which worked but this one was more preferred. I
will be pleased if you let me know other solutions you may find.
Jamal
-- Original Message --
From: "Ann Marinas" <ka_marinas@.xtra.co.nz>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Sent: Sunday, April 10, 2005 2:41 PM
Subject: Separate Webserver and SQL Server -- error when connecting asp.net
app to a database
> Hi all,
> I would like to ask for some help regarding separating the asp.net
> webserver and the sql server.
> I have created an asp.net application for a certain company. Initially, we
> installed both the iis and sql server in a single machine. Not too long
> ago, the machine had some hardware problems, and management has decided to
> purchase new servers, for both asp.net and sql server.
> Once we installed my webapp on the first server and the sql server on
> another, we have encountered some errors with it. Basically, the exception
> that keeps on saying was:
> "SQL Server database does not exist or access denied."
> Tried creating a windows account for the webapp to use to connect and
> configure it to the sql server, but it does not work.
> Tried also connecting with the database using a SQL Server account, but to
> no avail.
> Please help! I would really appreciate it!!
>
> Regards,
> Ann Marinas
Separating application logic and content from its presentation
I am about to develop a simple Content Management system – main purpose
would be posting articles. I am trying to find some ideas/ sample
architecture showing how to separate application logic and content from its
presentation. I would like to use some kind of predefined templates (only
developer can cerate new templates); each template would be composed of
certain controls and in would have some specific layout. The default.aspx
would be created dynamically based on the template specified.
I checked out DotNetNuke and Community Starter Kit
(http://asp.net/Default.aspx?tabindex=8&tabid=47). They are very good, but
too complex for my need.
Any hints would be greatly appreciated,
GregJust create the different modules (news, links, events, etc) and make sure t
o
use styles for all the different visual items. Then its really just a matter
of using different CSS files. You only have to specify which CSS to use then
.
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
"Greg" wrote:
> Hi,
> I am about to develop a simple Content Management system – main purpose
> would be posting articles. I am trying to find some ideas/ sample
> architecture showing how to separate application logic and content from it
s
> presentation. I would like to use some kind of predefined templates (only
> developer can cerate new templates); each template would be composed of
> certain controls and in would have some specific layout. The default.aspx
> would be created dynamically based on the template specified.
>
> I checked out DotNetNuke and Community Starter Kit
> (http://asp.net/Default.aspx?tabindex=8&tabid=47). They are very good, but
> too complex for my need.
> Any hints would be greatly appreciated,
> Greg
>
Separating application logic and content from its presentation
I am about to develop a simple Content Management system – main purpose
would be posting articles. I am trying to find some ideas/ sample
architecture showing how to separate application logic and content from its
presentation. I would like to use some kind of predefined templates (only
developer can cerate new templates); each template would be composed of
certain controls and in would have some specific layout. The default.aspx
would be created dynamically based on the template specified.
I checked out DotNetNuke and Community Starter Kit
(http://asp.net/Default.aspx?tabindex=8&tabid=47). They are very good, but
too complex for my need.
Any hints would be greatly appreciated,
GregJust create the different modules (news, links, events, etc) and make sure to
use styles for all the different visual items. Then its really just a matter
of using different CSS files. You only have to specify which CSS to use then.
--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
"Greg" wrote:
> Hi,
> I am about to develop a simple Content Management system – main purpose
> would be posting articles. I am trying to find some ideas/ sample
> architecture showing how to separate application logic and content from its
> presentation. I would like to use some kind of predefined templates (only
> developer can cerate new templates); each template would be composed of
> certain controls and in would have some specific layout. The default.aspx
> would be created dynamically based on the template specified.
>
> I checked out DotNetNuke and Community Starter Kit
> (http://asp.net/Default.aspx?tabindex=8&tabid=47). They are very good, but
> too complex for my need.
> Any hints would be greatly appreciated,
> Greg
Seperate Content from Code
Can anyone point me in the right direction of the best way to encapsulate the VB code into its own seperate file and then rerefence this from the form in the HTML page?
Hi,
you could place the code into separate aspx.vb file into its own class deriving form System.Web.UI.Page. Then putting the aspx to inherit from this code-behind class (with Inherits directive) would work.
Say you have files
page1.aspx (important ones are CodeFile and Inherits attributes)
<%@. Page Language="VB" AutoEventWireup="false" CodeFile="page1.aspx.vb" Inherits="page1" %>
...
page1.aspx.vb
Partial Class page1
Inherits System.Web.UI.Page
End Class
When you could put code into aspx.vb file into the class.
More information :http://www.asp.net/QuickStart/aspnet/doc/pages/codebehind.aspx
Of course if have code & logic which is such that it's common to more than one form, you might want to consider having a separate component (class library or in App_Code) where you could centralize logic that is needed in multiple places.
Thanks joteke, I think I'm slowly getting there.
So the .aspx file inherits the class that you create in the aspx.vb file ?
Then within that class you simply insert all the code that was previously in the <script> section at the top of the .aspx file?
What does the'AutoEventWireup' attribute do?
Also, do i need to import the namespaces in the aspx file or the aspx.vb file ?
duncanhall:
So the .aspx file inherits the class that you create in the aspx.vb file ?
Yes. Basically with partial classes in ASP.NET 2.0 (when using CodeFile attribute) a second partial class is created. This class contains control declarations for controls residing on aspx (removes the need for you to declare them on aspx.vb as you had to do with ASP.NEt v1.x).
These two partial classes are merged when compilation occurs and are used as base class for class which is created when the actual aspx is parsed and compiled (yes, basically the aspx itself)
duncanhall:
Then within that class you simply insert all the code that was previously in the <script> section at the top of the .aspx file?
Yes, note that the code-behind class is now equally part of your page.
duncanhall:
What does the'AutoEventWireup' attribute do?
It indicates whether Page's event are autowired. If enabled, it means that you have a method which matches Page_[EventName] or [ControlID]_[EventName] name so that method would automatically be assigned as event handler for the correspondng event of P?ager or the Control. Normally these event methods need to be wired explicitly.
See:ASP.NET Web Server Control Event Model
If code is in code-behind, then you import in code-behind.
Thanks a lot joteke, everything seems to make sense now, and my first app is pretty much finished!
seperate service thread
for emails that need to be send out based upon certain events so that the
main request/response threads aren't responsible for the communication with
the smtp server, etc. I don't want to create a seperate thread for every
instance in which a notification must be sent...I'd rather record the
necessary information to the db or web cache and let the subsystem be
responsible for it from there. What is the best way to go about
this...should I just launch another thread upon application start? What do
I do w/ the thread when it has no responsibility. Should it just loop, look
for work and do work/sleep for a few seconds, etc?
I'm sure someone has done something like this before or come across some
article, etc...I appreciate any comments.
~PaulI suggest you look into using a Windows Service to handle such background
tasks.
Here's more information on Windows Services:
http://msdn.microsoft.com/library/d...dowsService.asp
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"PJ" <pjwal@.hotmail.com> wrote in message
news:uEVqiE8iEHA.704@.TK2MSFTNGP09.phx.gbl...
> I'd like to create a subsystem in my asp.net application that is
> responsible
> for emails that need to be send out based upon certain events so that the
> main request/response threads aren't responsible for the communication
> with
> the smtp server, etc. I don't want to create a seperate thread for every
> instance in which a notification must be sent...I'd rather record the
> necessary information to the db or web cache and let the subsystem be
> responsible for it from there. What is the best way to go about
> this...should I just launch another thread upon application start? What
> do
> I do w/ the thread when it has no responsibility. Should it just loop,
> look
> for work and do work/sleep for a few seconds, etc?
> I'm sure someone has done something like this before or come across some
> article, etc...I appreciate any comments.
> ~Paul
"PJ" <pjwal@.hotmail.com> wrote in message
news:uEVqiE8iEHA.704@.TK2MSFTNGP09.phx.gbl...
> I'd like to create a subsystem in my asp.net application that is
responsible
> for emails that need to be send out based upon certain events so that the
> main request/response threads aren't responsible for the communication
with
> the smtp server, etc. I don't want to create a seperate thread for every
> instance in which a notification must be sent...I'd rather record the
> necessary information to the db or web cache and let the subsystem be
> responsible for it from there. What is the best way to go about
> this...should I just launch another thread upon application start? What
do
> I do w/ the thread when it has no responsibility. Should it just loop,
look
> for work and do work/sleep for a few seconds, etc?
> I'm sure someone has done something like this before or come across some
> article, etc...I appreciate any comments.
Here's a type called SingleThreadWorkQueue for this kind of thing. When you
create a SingleThreadWorkQueue is creates a thread and a Queue. The thread
pulls items off the queue and then invokes a delegate (a function outside
the type), and passes it whatever was on the queue.
So you would just bundle up the information to send an email into an object,
and pass it to SingleThreadWorkQueue.AddWork. The worker thread would then
dequeue the work and invoke your work function.
Like this:
-- somewhere in global scope --
public shared OutgoingEmailQueue as new SingleThreadWorkQueue(addressOf
SendAnEmail)
public shared sub SendAnEmail(work as Object)
dim em as MyEmailInfo = directcast(work,MyEmailInfo)
--send the email
end sub
-- anywhere you want to generate an email, somehting like --
MyGlobal.OutgoingEmailQueue.AddWork(new EmailObject("joe@.hotmail.com","helo,
joe"))
Private Class SingleThreadWorkQueue
Private workQueue As Queue = Queue.Synchronized(New Queue())
Private wp As DoWork
Private wt As Thread
Public Delegate Sub DoWork(ByVal w As Object)
Public Event ExceptionOccured(ByVal e As Exception)
Public Sub New(ByVal WorkProc As DoWork)
wp = WorkProc
wt = New Thread(AddressOf workerThreadProc)
wt.IsBackground = True
wt.Name = "worker thread for " & wp.Target.GetType.Name & "." &
wp.Method.Name
wt.Start()
End Sub
Private Sub workerThreadProc()
SyncLock workQueue
Do
Monitor.Wait(workQueue, 5000)
Do While workQueue.Count > 0
Try
Dim w As Object = workQueue.Dequeue
wp.Invoke(w)
Catch ex As Exception
RaiseEvent ExceptionOccured(ex)
End Try
Loop
Loop
End SyncLock
End Sub
Public Sub AddWork(ByVal work As Object)
workQueue.Enqueue(work)
If Monitor.TryEnter(workQueue) Then
Monitor.Pulse(workQueue)
Monitor.Exit(workQueue)
End If
End Sub
End Class
This could work in some cases, but if the thread is especially long running
I'm afraid it could time out once the initiating thread (the ASP.NET page)
is long gone. A windows service should never time out, so it might be a bit
more reliable. A Queue could still be used to store up the list of to-dos.
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:uMVqAKEjEHA.3968@.TK2MSFTNGP10.phx.gbl...
> "PJ" <pjwal@.hotmail.com> wrote in message
> news:uEVqiE8iEHA.704@.TK2MSFTNGP09.phx.gbl...
>> I'd like to create a subsystem in my asp.net application that is
> responsible
>> for emails that need to be send out based upon certain events so that the
>> main request/response threads aren't responsible for the communication
> with
>> the smtp server, etc. I don't want to create a seperate thread for every
>> instance in which a notification must be sent...I'd rather record the
>> necessary information to the db or web cache and let the subsystem be
>> responsible for it from there. What is the best way to go about
>> this...should I just launch another thread upon application start? What
> do
>> I do w/ the thread when it has no responsibility. Should it just loop,
> look
>> for work and do work/sleep for a few seconds, etc?
>>
>> I'm sure someone has done something like this before or come across some
>> article, etc...I appreciate any comments.
>
> Here's a type called SingleThreadWorkQueue for this kind of thing. When
> you
> create a SingleThreadWorkQueue is creates a thread and a Queue. The
> thread
> pulls items off the queue and then invokes a delegate (a function outside
> the type), and passes it whatever was on the queue.
> So you would just bundle up the information to send an email into an
> object,
> and pass it to SingleThreadWorkQueue.AddWork. The worker thread would
> then
> dequeue the work and invoke your work function.
> Like this:
> -- somewhere in global scope --
> public shared OutgoingEmailQueue as new SingleThreadWorkQueue(addressOf
> SendAnEmail)
> public shared sub SendAnEmail(work as Object)
> dim em as MyEmailInfo = directcast(work,MyEmailInfo)
> --send the email
> end sub
>
> -- anywhere you want to generate an email, somehting like --
>
> MyGlobal.OutgoingEmailQueue.AddWork(new
> EmailObject("joe@.hotmail.com","helo,
> joe"))
>
>
> Private Class SingleThreadWorkQueue
> Private workQueue As Queue = Queue.Synchronized(New Queue())
> Private wp As DoWork
> Private wt As Thread
> Public Delegate Sub DoWork(ByVal w As Object)
> Public Event ExceptionOccured(ByVal e As Exception)
> Public Sub New(ByVal WorkProc As DoWork)
> wp = WorkProc
> wt = New Thread(AddressOf workerThreadProc)
> wt.IsBackground = True
> wt.Name = "worker thread for " & wp.Target.GetType.Name & "." &
> wp.Method.Name
> wt.Start()
> End Sub
> Private Sub workerThreadProc()
> SyncLock workQueue
> Do
> Monitor.Wait(workQueue, 5000)
> Do While workQueue.Count > 0
> Try
> Dim w As Object = workQueue.Dequeue
> wp.Invoke(w)
> Catch ex As Exception
> RaiseEvent ExceptionOccured(ex)
> End Try
> Loop
> Loop
> End SyncLock
> End Sub
> Public Sub AddWork(ByVal work As Object)
> workQueue.Enqueue(work)
> If Monitor.TryEnter(workQueue) Then
> Monitor.Pulse(workQueue)
> Monitor.Exit(workQueue)
> End If
> End Sub
> End Class
"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:uLBHzYGjEHA.1348@.tk2msftngp13.phx.gbl...
> This could work in some cases, but if the thread is especially long
running
> I'm afraid it could time out once the initiating thread (the ASP.NET page)
> is long gone. A windows service should never time out, so it might be a
bit
> more reliable. A Queue could still be used to store up the list of
to-dos.
You wouldn't want to run especially long running things this way. Just
things that take too long to do while your user is waiting. Sending an
email is a perfect use because it can take about a second to do all the SMTP
stuff, and you just don't need to add that to your user's wait time. I also
use this mechanism to write to my log file. Multiple threads can add log
entries very quickly and the worker thread writes them all out to disk.
Things you might be tempted to use the ThreadPool.QueueUserWorkItem for if
that weren't frowned upon in asp.net, and things that require access from a
single thread, like a file.
A service will work, but for something like this I think it's not really
worth the hastle of administering and configuring the interprocess
communication.
David
This is good stuff. Excuse my ignorance, but why is it necessary to use a
delegate? Why can't the wrokerThreadProc just call SendAnEmail directly?
Thanks~
Paul
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:uMVqAKEjEHA.3968@.TK2MSFTNGP10.phx.gbl...
> "PJ" <pjwal@.hotmail.com> wrote in message
> news:uEVqiE8iEHA.704@.TK2MSFTNGP09.phx.gbl...
> > I'd like to create a subsystem in my asp.net application that is
> responsible
> > for emails that need to be send out based upon certain events so that
the
> > main request/response threads aren't responsible for the communication
> with
> > the smtp server, etc. I don't want to create a seperate thread for
every
> > instance in which a notification must be sent...I'd rather record the
> > necessary information to the db or web cache and let the subsystem be
> > responsible for it from there. What is the best way to go about
> > this...should I just launch another thread upon application start?
What
> do
> > I do w/ the thread when it has no responsibility. Should it just loop,
> look
> > for work and do work/sleep for a few seconds, etc?
> > I'm sure someone has done something like this before or come across some
> > article, etc...I appreciate any comments.
>
> Here's a type called SingleThreadWorkQueue for this kind of thing. When
you
> create a SingleThreadWorkQueue is creates a thread and a Queue. The
thread
> pulls items off the queue and then invokes a delegate (a function outside
> the type), and passes it whatever was on the queue.
> So you would just bundle up the information to send an email into an
object,
> and pass it to SingleThreadWorkQueue.AddWork. The worker thread would
then
> dequeue the work and invoke your work function.
> Like this:
> -- somewhere in global scope --
> public shared OutgoingEmailQueue as new SingleThreadWorkQueue(addressOf
> SendAnEmail)
> public shared sub SendAnEmail(work as Object)
> dim em as MyEmailInfo = directcast(work,MyEmailInfo)
> --send the email
> end sub
>
> -- anywhere you want to generate an email, somehting like --
>
> MyGlobal.OutgoingEmailQueue.AddWork(new
EmailObject("joe@.hotmail.com","helo,
> joe"))
>
>
> Private Class SingleThreadWorkQueue
> Private workQueue As Queue = Queue.Synchronized(New Queue())
> Private wp As DoWork
> Private wt As Thread
> Public Delegate Sub DoWork(ByVal w As Object)
> Public Event ExceptionOccured(ByVal e As Exception)
> Public Sub New(ByVal WorkProc As DoWork)
> wp = WorkProc
> wt = New Thread(AddressOf workerThreadProc)
> wt.IsBackground = True
> wt.Name = "worker thread for " & wp.Target.GetType.Name & "." &
> wp.Method.Name
> wt.Start()
> End Sub
> Private Sub workerThreadProc()
> SyncLock workQueue
> Do
> Monitor.Wait(workQueue, 5000)
> Do While workQueue.Count > 0
> Try
> Dim w As Object = workQueue.Dequeue
> wp.Invoke(w)
> Catch ex As Exception
> RaiseEvent ExceptionOccured(ex)
> End Try
> Loop
> Loop
> End SyncLock
> End Sub
> Public Sub AddWork(ByVal work As Object)
> workQueue.Enqueue(work)
> If Monitor.TryEnter(workQueue) Then
> Monitor.Pulse(workQueue)
> Monitor.Exit(workQueue)
> End If
> End Sub
> End Class
I'm curious about this as well. What exactly would time out? I assume
"time out" means certain object instances would be recycled? If the page
instance is recycled, how will it affect a worker thread if the thread is
not referencing any of the page's members? Will an object created in the
page, i.e. an EmailObject, that's passed to the queue get recycyled if the
page instance does?
Thanks for the clarification?
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:%23whL8LHjEHA.1776@.TK2MSFTNGP15.phx.gbl...
> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> news:uLBHzYGjEHA.1348@.tk2msftngp13.phx.gbl...
> > This could work in some cases, but if the thread is especially long
> running
> > I'm afraid it could time out once the initiating thread (the ASP.NET
page)
> > is long gone. A windows service should never time out, so it might be a
> bit
> > more reliable. A Queue could still be used to store up the list of
> to-dos.
> You wouldn't want to run especially long running things this way. Just
> things that take too long to do while your user is waiting. Sending an
> email is a perfect use because it can take about a second to do all the
SMTP
> stuff, and you just don't need to add that to your user's wait time. I
also
> use this mechanism to write to my log file. Multiple threads can add log
> entries very quickly and the worker thread writes them all out to disk.
> Things you might be tempted to use the ThreadPool.QueueUserWorkItem for if
> that weren't frowned upon in asp.net, and things that require access from
a
> single thread, like a file.
> A service will work, but for something like this I think it's not really
> worth the hastle of administering and configuring the interprocess
> communication.
> David
Once a page has been rendered, any threads it created are eventually
orphaned and become potential targets for the .net garbage collector. How
often the garbage collector runs varies, depending on the load of your
server & such.
David is right that this won't likely be a problem if all the thread is
doing is sending a quick email to an exchange queue. Once the email has
been generated and is in the queue, it shouldn't matter if the thread that
created it gets recycled. However, if the code is only doing something
really quick like that then I'm not sure why you'd need a separate thread
for it anyway.
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"PJ" <pjwal@.hotmail.com> wrote in message
news:%23bJ78LIjEHA.3928@.TK2MSFTNGP11.phx.gbl...
> I'm curious about this as well. What exactly would time out? I assume
> "time out" means certain object instances would be recycled? If the page
> instance is recycled, how will it affect a worker thread if the thread is
> not referencing any of the page's members? Will an object created in the
> page, i.e. an EmailObject, that's passed to the queue get recycyled if the
> page instance does?
> Thanks for the clarification?
>
> "David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
> message news:%23whL8LHjEHA.1776@.TK2MSFTNGP15.phx.gbl...
>>
>> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
>> news:uLBHzYGjEHA.1348@.tk2msftngp13.phx.gbl...
>> > This could work in some cases, but if the thread is especially long
>> running
>> > I'm afraid it could time out once the initiating thread (the ASP.NET
> page)
>> > is long gone. A windows service should never time out, so it might be
>> > a
>> bit
>> > more reliable. A Queue could still be used to store up the list of
>> to-dos.
>>>
>> You wouldn't want to run especially long running things this way. Just
>> things that take too long to do while your user is waiting. Sending an
>> email is a perfect use because it can take about a second to do all the
> SMTP
>> stuff, and you just don't need to add that to your user's wait time. I
> also
>> use this mechanism to write to my log file. Multiple threads can add log
>> entries very quickly and the worker thread writes them all out to disk.
>> Things you might be tempted to use the ThreadPool.QueueUserWorkItem for
>> if
>> that weren't frowned upon in asp.net, and things that require access from
> a
>> single thread, like a file.
>>
>> A service will work, but for something like this I think it's not really
>> worth the hastle of administering and configuring the interprocess
>> communication.
>>
>> David
>>
>>
There's a noticable difference when holding up the main response/request
thread at times. Also, some CDONTS errors seem to slip through any error
handling we have in place.
As far as orphaned threads...
What if I use a Singleton instance to create the thread? This singleton
could behave much like David's code snippet. The worker thread could be
created in the static constructor. Will the worker thread still be a target
for the garbage collector? I don't see how...I mean, if I add an item to
the web cache in a page instance, it doesn't get marked for garbage
collection, right?
Thanks for your time.
Public Class NotificationManager
Private Sub New()
End Sub
Shared Sub New()
'start thread with addressof Notify
End Sub
Private Shared ReadOnly _instance As NotificationManager = New
NotificationManager
Private _notificationList As Queue
Public Shared Function GetInstance() As NotificationManager
Return _instance
End Function
Public Sub AddWork(ByVal work as Object)
'add email data to queue
End Sub
Private Sub Notify
'loop, check queue, send email, etc
End Sub
End Class
'client code
NotificationManager.GetInstance().AddWork(myEmailO bject)
"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:OTwt$bIjEHA.592@.TK2MSFTNGP11.phx.gbl...
> Once a page has been rendered, any threads it created are eventually
> orphaned and become potential targets for the .net garbage collector. How
> often the garbage collector runs varies, depending on the load of your
> server & such.
> David is right that this won't likely be a problem if all the thread is
> doing is sending a quick email to an exchange queue. Once the email has
> been generated and is in the queue, it shouldn't matter if the thread that
> created it gets recycled. However, if the code is only doing something
> really quick like that then I'm not sure why you'd need a separate thread
> for it anyway.
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://Steve.Orr.net
>
> "PJ" <pjwal@.hotmail.com> wrote in message
> news:%23bJ78LIjEHA.3928@.TK2MSFTNGP11.phx.gbl...
> > I'm curious about this as well. What exactly would time out? I assume
> > "time out" means certain object instances would be recycled? If the
page
> > instance is recycled, how will it affect a worker thread if the thread
is
> > not referencing any of the page's members? Will an object created in
the
> > page, i.e. an EmailObject, that's passed to the queue get recycyled if
the
> > page instance does?
> > Thanks for the clarification?
> > "David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
> > message news:%23whL8LHjEHA.1776@.TK2MSFTNGP15.phx.gbl...
> >>
> >> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> >> news:uLBHzYGjEHA.1348@.tk2msftngp13.phx.gbl...
> >> > This could work in some cases, but if the thread is especially long
> >> running
> >> > I'm afraid it could time out once the initiating thread (the ASP.NET
> > page)
> >> > is long gone. A windows service should never time out, so it might
be
> >> > a
> >> bit
> >> > more reliable. A Queue could still be used to store up the list of
> >> to-dos.
> >> >>
> >> You wouldn't want to run especially long running things this way. Just
> >> things that take too long to do while your user is waiting. Sending an
> >> email is a perfect use because it can take about a second to do all the
> > SMTP
> >> stuff, and you just don't need to add that to your user's wait time. I
> > also
> >> use this mechanism to write to my log file. Multiple threads can add
log
> >> entries very quickly and the worker thread writes them all out to disk.
> >> Things you might be tempted to use the ThreadPool.QueueUserWorkItem for
> >> if
> >> that weren't frowned upon in asp.net, and things that require access
from
> > a
> >> single thread, like a file.
> >>
> >> A service will work, but for something like this I think it's not
really
> >> worth the hastle of administering and configuring the interprocess
> >> communication.
> >>
> >> David
> >>
> >>
Also, if the Singleton instance holds a reference to the thread ( as a
private class member ), will that not prevent the thread from being garbage
collected?
"PJ" <pjwal@.hotmail.com> wrote in message
news:ODtMq0IjEHA.592@.TK2MSFTNGP11.phx.gbl...
> There's a noticable difference when holding up the main response/request
> thread at times. Also, some CDONTS errors seem to slip through any error
> handling we have in place.
> As far as orphaned threads...
> What if I use a Singleton instance to create the thread? This singleton
> could behave much like David's code snippet. The worker thread could be
> created in the static constructor. Will the worker thread still be a
target
> for the garbage collector? I don't see how...I mean, if I add an item to
> the web cache in a page instance, it doesn't get marked for garbage
> collection, right?
> Thanks for your time.
> Public Class NotificationManager
> Private Sub New()
> End Sub
> Shared Sub New()
> 'start thread with addressof Notify
> End Sub
> Private Shared ReadOnly _instance As NotificationManager = New
> NotificationManager
> Private _notificationList As Queue
> Public Shared Function GetInstance() As NotificationManager
> Return _instance
> End Function
> Public Sub AddWork(ByVal work as Object)
> 'add email data to queue
> End Sub
> Private Sub Notify
> 'loop, check queue, send email, etc
> End Sub
> End Class
> 'client code
> NotificationManager.GetInstance().AddWork(myEmailO bject)
>
> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> news:OTwt$bIjEHA.592@.TK2MSFTNGP11.phx.gbl...
> > Once a page has been rendered, any threads it created are eventually
> > orphaned and become potential targets for the .net garbage collector.
How
> > often the garbage collector runs varies, depending on the load of your
> > server & such.
> > David is right that this won't likely be a problem if all the thread is
> > doing is sending a quick email to an exchange queue. Once the email has
> > been generated and is in the queue, it shouldn't matter if the thread
that
> > created it gets recycled. However, if the code is only doing something
> > really quick like that then I'm not sure why you'd need a separate
thread
> > for it anyway.
> > --
> > I hope this helps,
> > Steve C. Orr, MCSD, MVP
> > http://Steve.Orr.net
> > "PJ" <pjwal@.hotmail.com> wrote in message
> > news:%23bJ78LIjEHA.3928@.TK2MSFTNGP11.phx.gbl...
> > > I'm curious about this as well. What exactly would time out? I
assume
> > > "time out" means certain object instances would be recycled? If the
> page
> > > instance is recycled, how will it affect a worker thread if the thread
> is
> > > not referencing any of the page's members? Will an object created in
> the
> > > page, i.e. an EmailObject, that's passed to the queue get recycyled if
> the
> > > page instance does?
> > > > Thanks for the clarification?
> > > > > "David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
> > > message news:%23whL8LHjEHA.1776@.TK2MSFTNGP15.phx.gbl...
> > >>
> > >> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> > >> news:uLBHzYGjEHA.1348@.tk2msftngp13.phx.gbl...
> > >> > This could work in some cases, but if the thread is especially long
> > >> running
> > >> > I'm afraid it could time out once the initiating thread (the
ASP.NET
> > > page)
> > >> > is long gone. A windows service should never time out, so it might
> be
> > >> > a
> > >> bit
> > >> > more reliable. A Queue could still be used to store up the list of
> > >> to-dos.
> > >> > >>
> > >> You wouldn't want to run especially long running things this way.
Just
> > >> things that take too long to do while your user is waiting. Sending
an
> > >> email is a perfect use because it can take about a second to do all
the
> > > SMTP
> > >> stuff, and you just don't need to add that to your user's wait time.
I
> > > also
> > >> use this mechanism to write to my log file. Multiple threads can add
> log
> > >> entries very quickly and the worker thread writes them all out to
disk.
> > >> Things you might be tempted to use the ThreadPool.QueueUserWorkItem
for
> > >> if
> > >> that weren't frowned upon in asp.net, and things that require access
> from
> > > a
> > >> single thread, like a file.
> > >>
> > >> A service will work, but for something like this I think it's not
> really
> > >> worth the hastle of administering and configuring the interprocess
> > >> communication.
> > >>
> > >> David
> > >>
> > >>
> >
"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:OTwt$bIjEHA.592@.TK2MSFTNGP11.phx.gbl...
> Once a page has been rendered, any threads it created are eventually
> orphaned and become potential targets for the .net garbage collector. How
> often the garbage collector runs varies, depending on the load of your
> server & such.
Nope. Threads are roots. A running thread and everything it references is
safe from the garbage collector. Even if this weren't the case, the static
reference to the thread would keep it reachable and keep it from being
collected.
David
"PJ" <pjwal@.hotmail.com> wrote in message
news:OeoRvLJjEHA.3536@.TK2MSFTNGP10.phx.gbl...
> Also, if the Singleton instance holds a reference to the thread ( as a
> private class member ), will that not prevent the thread from being
garbage
> collected?
The garbage collector never collects running threads. But you are right,
singletons are never collected because of the static (shared in VB)
reference. Classes are roots, just like threads are roots, and so any
object referenced by a class is not elegible for collection.
David
seperate service thread
for emails that need to be send out based upon certain events so that the
main request/response threads aren't responsible for the communication with
the smtp server, etc. I don't want to create a seperate thread for every
instance in which a notification must be sent...I'd rather record the
necessary information to the db or web cache and let the subsystem be
responsible for it from there. What is the best way to go about
this...should I just launch another thread upon application start? What do
I do w/ the thread when it has no responsibility. Should it just loop, look
for work and do work/sleep for a few seconds, etc?
I'm sure someone has done something like this before or come across some
article, etc...I appreciate any comments.
~PaulI suggest you look into using a Windows Service to handle such background
tasks.
Here's more information on Windows Services:
http://msdn.microsoft.com/library/d...dowsService.asp
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"PJ" <pjwal@.hotmail.com> wrote in message
news:uEVqiE8iEHA.704@.TK2MSFTNGP09.phx.gbl...
> I'd like to create a subsystem in my asp.net application that is
> responsible
> for emails that need to be send out based upon certain events so that the
> main request/response threads aren't responsible for the communication
> with
> the smtp server, etc. I don't want to create a seperate thread for every
> instance in which a notification must be sent...I'd rather record the
> necessary information to the db or web cache and let the subsystem be
> responsible for it from there. What is the best way to go about
> this...should I just launch another thread upon application start? What
> do
> I do w/ the thread when it has no responsibility. Should it just loop,
> look
> for work and do work/sleep for a few seconds, etc?
> I'm sure someone has done something like this before or come across some
> article, etc...I appreciate any comments.
> ~Paul
>
"PJ" <pjwal@.hotmail.com> wrote in message
news:uEVqiE8iEHA.704@.TK2MSFTNGP09.phx.gbl...
> I'd like to create a subsystem in my asp.net application that is
responsible
> for emails that need to be send out based upon certain events so that the
> main request/response threads aren't responsible for the communication
with
> the smtp server, etc. I don't want to create a seperate thread for every
> instance in which a notification must be sent...I'd rather record the
> necessary information to the db or web cache and let the subsystem be
> responsible for it from there. What is the best way to go about
> this...should I just launch another thread upon application start? What
do
> I do w/ the thread when it has no responsibility. Should it just loop,
look
> for work and do work/sleep for a few seconds, etc?
> I'm sure someone has done something like this before or come across some
> article, etc...I appreciate any comments.
Here's a type called SingleThreadWorkQueue for this kind of thing. When you
create a SingleThreadWorkQueue is creates a thread and a Queue. The thread
pulls items off the queue and then invokes a delegate (a function outside
the type), and passes it whatever was on the queue.
So you would just bundle up the information to send an email into an object,
and pass it to SingleThreadWorkQueue.AddWork. The worker thread would then
dequeue the work and invoke your work function.
Like this:
-- somewhere in global scope --
public shared OutgoingEmailQueue as new SingleThreadWorkQueue(addressOf
SendAnEmail)
public shared sub SendAnEmail(work as Object)
dim em as MyEmailInfo = directcast(work,MyEmailInfo)
--send the email
end sub
-- anywhere you want to generate an email, somehting like --
MyGlobal.OutgoingEmailQueue.AddWork(new EmailObject("joe@.hotmail.com","helo,
joe"))
Private Class SingleThreadWorkQueue
Private workQueue As Queue = Queue.Synchronized(New Queue())
Private wp As DoWork
Private wt As Thread
Public Delegate Sub DoWork(ByVal w As Object)
Public Event ExceptionOccured(ByVal e As Exception)
Public Sub New(ByVal WorkProc As DoWork)
wp = WorkProc
wt = New Thread(AddressOf workerThreadProc)
wt.IsBackground = True
wt.Name = "worker thread for " & wp.Target.GetType.Name & "." &
wp.Method.Name
wt.Start()
End Sub
Private Sub workerThreadProc()
SyncLock workQueue
Do
Monitor.Wait(workQueue, 5000)
Do While workQueue.Count > 0
Try
Dim w As Object = workQueue.Dequeue
wp.Invoke(w)
Catch ex As Exception
RaiseEvent ExceptionOccured(ex)
End Try
Loop
Loop
End SyncLock
End Sub
Public Sub AddWork(ByVal work As Object)
workQueue.Enqueue(work)
If Monitor.TryEnter(workQueue) Then
Monitor.Pulse(workQueue)
Monitor.Exit(workQueue)
End If
End Sub
End Class
This could work in some cases, but if the thread is especially long running
I'm afraid it could time out once the initiating thread (the ASP.NET page)
is long gone. A windows service should never time out, so it might be a bit
more reliable. A Queue could still be used to store up the list of to-dos.
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:uMVqAKEjEHA.3968@.TK2MSFTNGP10.phx.gbl...
> "PJ" <pjwal@.hotmail.com> wrote in message
> news:uEVqiE8iEHA.704@.TK2MSFTNGP09.phx.gbl...
> responsible
> with
> do
> look
>
> Here's a type called SingleThreadWorkQueue for this kind of thing. When
> you
> create a SingleThreadWorkQueue is creates a thread and a Queue. The
> thread
> pulls items off the queue and then invokes a delegate (a function outside
> the type), and passes it whatever was on the queue.
> So you would just bundle up the information to send an email into an
> object,
> and pass it to SingleThreadWorkQueue.AddWork. The worker thread would
> then
> dequeue the work and invoke your work function.
> Like this:
> -- somewhere in global scope --
> public shared OutgoingEmailQueue as new SingleThreadWorkQueue(addressOf
> SendAnEmail)
> public shared sub SendAnEmail(work as Object)
> dim em as MyEmailInfo = directcast(work,MyEmailInfo)
> --send the email
> end sub
>
> -- anywhere you want to generate an email, somehting like --
>
> MyGlobal.OutgoingEmailQueue.AddWork(new
> EmailObject("joe@.hotmail.com","helo,
> joe"))
>
>
> Private Class SingleThreadWorkQueue
> Private workQueue As Queue = Queue.Synchronized(New Queue())
> Private wp As DoWork
> Private wt As Thread
> Public Delegate Sub DoWork(ByVal w As Object)
> Public Event ExceptionOccured(ByVal e As Exception)
> Public Sub New(ByVal WorkProc As DoWork)
> wp = WorkProc
> wt = New Thread(AddressOf workerThreadProc)
> wt.IsBackground = True
> wt.Name = "worker thread for " & wp.Target.GetType.Name & "." &
> wp.Method.Name
> wt.Start()
> End Sub
> Private Sub workerThreadProc()
> SyncLock workQueue
> Do
> Monitor.Wait(workQueue, 5000)
> Do While workQueue.Count > 0
> Try
> Dim w As Object = workQueue.Dequeue
> wp.Invoke(w)
> Catch ex As Exception
> RaiseEvent ExceptionOccured(ex)
> End Try
> Loop
> Loop
> End SyncLock
> End Sub
> Public Sub AddWork(ByVal work As Object)
> workQueue.Enqueue(work)
> If Monitor.TryEnter(workQueue) Then
> Monitor.Pulse(workQueue)
> Monitor.Exit(workQueue)
> End If
> End Sub
> End Class
>
"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:uLBHzYGjEHA.1348@.tk2msftngp13.phx.gbl...
> This could work in some cases, but if the thread is especially long
running
> I'm afraid it could time out once the initiating thread (the ASP.NET page)
> is long gone. A windows service should never time out, so it might be a
bit
> more reliable. A Queue could still be used to store up the list of
to-dos.
>
You wouldn't want to run especially long running things this way. Just
things that take too long to do while your user is waiting. Sending an
email is a perfect use because it can take about a second to do all the SMTP
stuff, and you just don't need to add that to your user's wait time. I also
use this mechanism to write to my log file. Multiple threads can add log
entries very quickly and the worker thread writes them all out to disk.
Things you might be tempted to use the ThreadPool.QueueUserWorkItem for if
that weren't frowned upon in asp.net, and things that require access from a
single thread, like a file.
A service will work, but for something like this I think it's not really
worth the hastle of administering and configuring the interprocess
communication.
David
This is good stuff. Excuse my ignorance, but why is it necessary to use a
delegate? Why can't the wrokerThreadProc just call SendAnEmail directly?
Thanks~
Paul
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:uMVqAKEjEHA.3968@.TK2MSFTNGP10.phx.gbl...
> "PJ" <pjwal@.hotmail.com> wrote in message
> news:uEVqiE8iEHA.704@.TK2MSFTNGP09.phx.gbl...
> responsible
the
> with
every
What
> do
> look
>
> Here's a type called SingleThreadWorkQueue for this kind of thing. When
you
> create a SingleThreadWorkQueue is creates a thread and a Queue. The
thread
> pulls items off the queue and then invokes a delegate (a function outside
> the type), and passes it whatever was on the queue.
> So you would just bundle up the information to send an email into an
object,
> and pass it to SingleThreadWorkQueue.AddWork. The worker thread would
then
> dequeue the work and invoke your work function.
> Like this:
> -- somewhere in global scope --
> public shared OutgoingEmailQueue as new SingleThreadWorkQueue(addressOf
> SendAnEmail)
> public shared sub SendAnEmail(work as Object)
> dim em as MyEmailInfo = directcast(work,MyEmailInfo)
> --send the email
> end sub
>
> -- anywhere you want to generate an email, somehting like --
>
> MyGlobal.OutgoingEmailQueue.AddWork(new
EmailObject("joe@.hotmail.com","helo,
> joe"))
>
>
> Private Class SingleThreadWorkQueue
> Private workQueue As Queue = Queue.Synchronized(New Queue())
> Private wp As DoWork
> Private wt As Thread
> Public Delegate Sub DoWork(ByVal w As Object)
> Public Event ExceptionOccured(ByVal e As Exception)
> Public Sub New(ByVal WorkProc As DoWork)
> wp = WorkProc
> wt = New Thread(AddressOf workerThreadProc)
> wt.IsBackground = True
> wt.Name = "worker thread for " & wp.Target.GetType.Name & "." &
> wp.Method.Name
> wt.Start()
> End Sub
> Private Sub workerThreadProc()
> SyncLock workQueue
> Do
> Monitor.Wait(workQueue, 5000)
> Do While workQueue.Count > 0
> Try
> Dim w As Object = workQueue.Dequeue
> wp.Invoke(w)
> Catch ex As Exception
> RaiseEvent ExceptionOccured(ex)
> End Try
> Loop
> Loop
> End SyncLock
> End Sub
> Public Sub AddWork(ByVal work As Object)
> workQueue.Enqueue(work)
> If Monitor.TryEnter(workQueue) Then
> Monitor.Pulse(workQueue)
> Monitor.Exit(workQueue)
> End If
> End Sub
> End Class
>
I'm curious about this as well. What exactly would time out? I assume
"time out" means certain object instances would be recycled? If the page
instance is recycled, how will it affect a worker thread if the thread is
not referencing any of the page's members? Will an object created in the
page, i.e. an EmailObject, that's passed to the queue get recycyled if the
page instance does?
Thanks for the clarification?
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:%23whL8LHjEHA.1776@.TK2MSFTNGP15.phx.gbl...
> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> news:uLBHzYGjEHA.1348@.tk2msftngp13.phx.gbl...
> running
page)
> bit
> to-dos.
> You wouldn't want to run especially long running things this way. Just
> things that take too long to do while your user is waiting. Sending an
> email is a perfect use because it can take about a second to do all the
SMTP
> stuff, and you just don't need to add that to your user's wait time. I
also
> use this mechanism to write to my log file. Multiple threads can add log
> entries very quickly and the worker thread writes them all out to disk.
> Things you might be tempted to use the ThreadPool.QueueUserWorkItem for if
> that weren't frowned upon in asp.net, and things that require access from
a
> single thread, like a file.
> A service will work, but for something like this I think it's not really
> worth the hastle of administering and configuring the interprocess
> communication.
> David
>
Once a page has been rendered, any threads it created are eventually
orphaned and become potential targets for the .net garbage collector. How
often the garbage collector runs varies, depending on the load of your
server & such.
David is right that this won't likely be a problem if all the thread is
doing is sending a quick email to an exchange queue. Once the email has
been generated and is in the queue, it shouldn't matter if the thread that
created it gets recycled. However, if the code is only doing something
really quick like that then I'm not sure why you'd need a separate thread
for it anyway.
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"PJ" <pjwal@.hotmail.com> wrote in message
news:%23bJ78LIjEHA.3928@.TK2MSFTNGP11.phx.gbl...
> I'm curious about this as well. What exactly would time out? I assume
> "time out" means certain object instances would be recycled? If the page
> instance is recycled, how will it affect a worker thread if the thread is
> not referencing any of the page's members? Will an object created in the
> page, i.e. an EmailObject, that's passed to the queue get recycyled if the
> page instance does?
> Thanks for the clarification?
>
> "David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
> message news:%23whL8LHjEHA.1776@.TK2MSFTNGP15.phx.gbl...
> page)
> SMTP
> also
> a
>
There's a noticable difference when holding up the main response/request
thread at times. Also, some CDONTS errors seem to slip through any error
handling we have in place.
As far as orphaned threads...
What if I use a Singleton instance to create the thread? This singleton
could behave much like David's code snippet. The worker thread could be
created in the static constructor. Will the worker thread still be a target
for the garbage collector? I don't see how...I mean, if I add an item to
the web cache in a page instance, it doesn't get marked for garbage
collection, right?
Thanks for your time.
Public Class NotificationManager
Private Sub New()
End Sub
Shared Sub New()
'start thread with addressof Notify
End Sub
Private Shared ReadOnly _instance As NotificationManager = New
NotificationManager
Private _notificationList As Queue
Public Shared Function GetInstance() As NotificationManager
Return _instance
End Function
Public Sub AddWork(ByVal work as Object)
'add email data to queue
End Sub
Private Sub Notify
'loop, check queue, send email, etc
End Sub
End Class
'client code
NotificationManager.GetInstance().AddWork(myEmailObject)
"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:OTwt$bIjEHA.592@.TK2MSFTNGP11.phx.gbl...
> Once a page has been rendered, any threads it created are eventually
> orphaned and become potential targets for the .net garbage collector. How
> often the garbage collector runs varies, depending on the load of your
> server & such.
> David is right that this won't likely be a problem if all the thread is
> doing is sending a quick email to an exchange queue. Once the email has
> been generated and is in the queue, it shouldn't matter if the thread that
> created it gets recycled. However, if the code is only doing something
> really quick like that then I'm not sure why you'd need a separate thread
> for it anyway.
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://Steve.Orr.net
>
> "PJ" <pjwal@.hotmail.com> wrote in message
> news:%23bJ78LIjEHA.3928@.TK2MSFTNGP11.phx.gbl...
page
is
the
the
be
log
from
really
>
Also, if the Singleton instance holds a reference to the thread ( as a
private class member ), will that not prevent the thread from being garbage
collected?
"PJ" <pjwal@.hotmail.com> wrote in message
news:ODtMq0IjEHA.592@.TK2MSFTNGP11.phx.gbl...
> There's a noticable difference when holding up the main response/request
> thread at times. Also, some CDONTS errors seem to slip through any error
> handling we have in place.
> As far as orphaned threads...
> What if I use a Singleton instance to create the thread? This singleton
> could behave much like David's code snippet. The worker thread could be
> created in the static constructor. Will the worker thread still be a
target
> for the garbage collector? I don't see how...I mean, if I add an item to
> the web cache in a page instance, it doesn't get marked for garbage
> collection, right?
> Thanks for your time.
> Public Class NotificationManager
> Private Sub New()
> End Sub
> Shared Sub New()
> 'start thread with addressof Notify
> End Sub
> Private Shared ReadOnly _instance As NotificationManager = New
> NotificationManager
> Private _notificationList As Queue
> Public Shared Function GetInstance() As NotificationManager
> Return _instance
> End Function
> Public Sub AddWork(ByVal work as Object)
> 'add email data to queue
> End Sub
> Private Sub Notify
> 'loop, check queue, send email, etc
> End Sub
> End Class
> 'client code
> NotificationManager.GetInstance().AddWork(myEmailObject)
>
> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> news:OTwt$bIjEHA.592@.TK2MSFTNGP11.phx.gbl...
How
that
thread
assume
> page
> is
> the
> the
ASP.NET
> be
Just
an
the
I
> log
disk.
for
> from
> really
>