Safe multithreading in ASP.Net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • who be dat?

    #16
    Re: Safe multithreading in ASP.Net

    Thanks fellas. I'm avoiding multithreading in my app.

    Chris Smith

    "Scott Allen" <bitmask@[nospam].fred.net> wrote in message
    news:g1s7h0litu auoe073dv2o1sco dru7vqlk4@4ax.c om...[color=blue][color=green]
    > >
    > >All due respect, but this is not something which should be attempted by
    > >anyone who does not consider himself an expert. And all due respect to
    > >"Visual Studio Magazine", but nobody should ever put risky code into
    > >production based on one of their articles. This kind of disjointed,[/color][/color]
    fluffy[color=blue][color=green]
    > >article is why I let my one and only subscription to that magazine lapse.
    > >Among other faults, the article skims over teaching about[/color][/color]
    synchronization ,[color=blue][color=green]
    > >and says nothing at all about what the extra thread can and cannot touch.[/color]
    >
    > Agreed! Articles like this run a good chance of starting more problems
    > than it solves.
    >
    > --s
    > --
    > Scott
    > http://www.OdeToCode.com[/color]


    Comment

    • Joe Fallon

      #17
      Re: Safe multithreading in ASP.Net

      I use Rick Strahl's SMTP class to send e-mails out asynchronously.
      It works great.

      The end user gets to continue navigating *immedialtely* while a


      --
      Joe Fallon



      "who be dat?" <whatever@dot.c om> wrote in message
      news:10h7mf9pc4 kvj94@corp.supe rnews.com...[color=blue]
      >
      > "Chris R. Timmons" <crtimmons@X_NO SPAM_Xcrtimmons inc.com> wrote in message
      > news:Xns953D3E0 7845EDcrtimmons crtimmonsin@207 .46.248.16...[color=green]
      > > "who be dat?" <whatever@dot.c om> wrote in
      > > news:10h5vp3huj p9452@corp.supe rnews.com:
      > >
      > >
      > > Chris,
      > >
      > > Do you really want to start a new thread for each application
      > > instance? Or do you just want a maximum of one thread running as
      > > long as there is at least one application instance running?
      > >
      > > Maybe you could also tell us more about the functional requirements
      > > of your app. Do users log into/out of your app? If so, when do you
      > > want the thread(s) to run - when the app starts or when the first
      > > user logs in? If users are required to log in, then maybe you could
      > > shut down the thread(s) when the user logs out, instead of when the
      > > app ends.
      > >
      > > --
      > > Hope this helps.
      > >
      > > Chris.[/color]
      >
      >
      > Hi Chris,
      >
      > I'm writing a bulletinboard application in order to learn ASP.Net. I've[/color]
      got[color=blue]
      > it going pretty good. You can see it at http://www.dotnetforum.net as a
      > matter of fact if you'd like. I'm now adding a new feature on my machine[/color]
      at[color=blue]
      > home. Once this feature is fully implemented and debugged, I will[/color]
      transfer[color=blue]
      > the update to the previously mentioned website. This feature will email
      > users when someone responds to a topic the user is watching letting that
      > user know someone has responded to a topic and provide a link the user can
      > click on to view the topic in their web browser. This is feature is[/color]
      fairly[color=blue]
      > typical among such applications.
      >
      > I could just run through the code to send the emails to users everytime a
      > user responds which after my experiment in multi-threading I'm considering
      > doing. However, I was concerned about performance on a busy website.
      > Everytime a user responds, the code will look through the tables, figure[/color]
      out[color=blue]
      > all the emails it needs to send, and send all the emails. Not to bad if[/color]
      one[color=blue]
      > or two users are online at once responding away. But, I became concerned
      > about performance when there would be a large number of users online
      > responding multiple times. The site would go through the email routine
      > every time a large amount of users responded to the site. When a single
      > user responds, that user might spawn a lot of emails to be sent out which
      > means they would have to wait till the emails were sent if there are a lot
      > people watching a particular topic. Add in the fact lots of people could[/color]
      be[color=blue]
      > responding at the same time and it could hurt website performance not to
      > mention individual users might notice the wait as the data was retrieved[/color]
      and[color=blue]
      > emails were sent. They would have to wait for those actions to complete
      > till they could move in the website. I thought I could help the site out[/color]
      by[color=blue]
      > creating a thread that ran in the background. The thread would search the
      > tables, send out the emails it needed to, then sleep for X amount of[/color]
      minutes[color=blue]
      > where X is determined by an app setting value in web.config. It's working
      > great. Problem is, the dang thread never terminates.
      >
      > What you think about this? I suppose I could just write a thread like the
      > following:
      >
      > Dim ThreadNotify as Thread 'declared in a code module as a public object[/color]
      to[color=blue]
      > be accessed anywhere
      >
      > When user responds the message is posted then this bit of code is[/color]
      executed:[color=blue]
      >
      > .
      > .
      > .
      > ThreadNotify = New Thread(New ThreadStart(Add ressOf EmailNotify))
      > ThreadNotify.St art()
      > .
      > .
      >
      > .
      >
      > Public Sub EmailNotify()
      >
      > Dim emails As New ForumEmail
      >
      > Do
      >
      > emails.EmailNot ify()
      >
      > End Sub
      >
      >
      >
      > Thing is, everytime someone responds a new thread will be created. But,
      > once the code for emailnotify reached the end sub statement, the thread
      > would terminate, right? I'd rather not create a thread everytime someone
      > responds but at least the grunt work would get done in another process and
      > hopefully the user won't notice it.
      >
      >
      >
      > Can you think of a better way to do this? Thanks!
      >
      > Chris Smith
      >
      >
      >
      >[/color]


      Comment

      Working...