Plip's Weblog

Phil Winstanley - British .NET chap based in Lancashire. Enjoys tea and tech. Working for Microsoft.

January 2005 - Posts

Multi Threading in ASP.NET

One of the applications I'm writing needs to call web services to sen data off to a third part, however the user doesn't need to see any kind of response from these web services, so what I wanted to do was fire off the web service calls in a different thread and return the page to the user while the web services are still being called.

This was great, until I came to need something from the HttpContext in my web service call, when using threads in ASP.NET the HttpContext is only avalibale to the main thread, and not to any child threads without some clever trickery.

Here's the methodology I've used to sort it: -

(Source:  http://www.codecomments.com/ASP_.NET/message351969.html )

 

MyThreadClass T = new MyThreadClass();

T.User = System.Web.HttpContext.Current.User.Identity.Name;

T.StartThread();

 

 

using System;

using System.Threading;

 

namespace Private

{

          public class MyThreadClass

          {

 

                   //Public Property to store the Username

                   private string _User = String.Empty;

                   public string User

                   {

                             get

                             {

                                      return _User;

                             }

                             set

                             {

                                      _User = value;

                             }

                   }

 

                   //Public method to start the Thread going.

                   public void StartThread()

                   {

                             System.Threading.Thread T = new System.Threading.Thread(new System.Threading.ThreadStart(Run));

                             T.Start();

                   }

 

                   //Private method that actuall does stuff, in this case e-mails the User property to me.

                   private void Run()

                   {                  BusinessProcesses.Emails.Send("phil@winstanley.name","phil@winstanley.name",String.Empty,"Thread",_User,System.Web.Mail.MailFormat.Text);

                   }

 

                   public MyThreadClass()

                   {

                   }

          }

}

 

Posted: Jan 20 2005, 10:48 PM by Plip | with 8 comment(s) |
Filed under: ,
Manchester, England, SQL Server Reporting Services, 1 Feb 2005

VBUG: SQL Server Reporting Services

Date: Tuesday 1 February 2005
Topic: VBUG Technical Seminar
Overview: Reporting Services is a comprehensive platform for developing and delivering enterprise reporting. This session will show you how to add Reporting Services into your applications, including how to design reports using Report Designer and interacting with the Report Server through web services. We’ll explore all of the new features in the 2005 version, including integration with Visual Studio 2005, enhanced support for Analysis Services, improved report interactivity and the new built-in controls for Windows
Venue: The Etrop Grange Hotel, Thorley Lane, Manchester Airport, M90 4EG
Times: 18.30 - 21.00 (semiar starts at 19.00)
Registration Details: Call 01753 648555
Price: FREE (conditions apply)

Posted: Jan 18 2005, 08:04 AM by Plip | with no comments
Filed under: , ,
Update from a Select

I know many people won't find this new, but it's the first time I've had to do it today.

I needed to update one table, from another table, and here's how I did it: -

UPDATE C

SET C.Phone = O.[Tel No],

C.Fax = O.[Fax]

FROM output$ O

          JOIN Contacts C

                   ON C.MemberId = O.MemberId

Posted: Jan 13 2005, 09:05 AM by Plip | with 39 comment(s) |
Filed under: ,
Review of 2004

I thought it was about time that I went through the last year and shared the high and low points with you all.

On the home front very little has changed, the only big change to my life this year was the passing of my driving test and purchase of a shiny new motor vehicle, meaning a farewell to British public transport and all its glories.

Reporting Services

Well, where do I start, Microsoft Sql Server Reporting Services. I lost several month of my life to this product and trying to get it working along side my applications. Here's what I learned: -

  • Don't bother with the SOAP API, instead directly call the Stored Procedures that are created during install.
  • Trying to write extenders for it is a nightmare, the documentation really lets down this product and you'll be continually tweaking many configuration files manually trying to get things working.
  • Get on to the Sql Server reporting Services newsgroup, it was a life saver.
  • Buy a copy of the Hitchhiker's Guide to Sql Server 2000 Reporting Services - it's fantastic.
  • Clear your desk, you'll need the time to play around with this product.

MsWebDev

The Microsoft Web Development Community designed specifically for UK Web developers has grown beyond our wildest dreams and is now host to some three hundred members with many really good people on there. 

The site was even featured in the December MSDN Flash that is authored by Microsoft UK's Mike Taultly to whom we are eternally grateful.

Microsoft UK have offered a great deal of support to the group and have several members of staff on the e-mail list watching what people are saying, they're listening to the needs of our developers and they're acting upon those needs.

Acclaim

I used to work for the internationally reknown games developer Acclaim Entertainment, alas this year they took their last breath of air and have gone under with the loss of hundreds of talented programmers and artists world wide. Several close friends lost their positions during the badly managed redundancies and are still suffering badly from it.

Best wishes to all the Ex-Acclaim staff, I hope you're going to get the help and jobs you deserve.

Microsoft MVP

Well they did it again, I'm an MVP for another year, still in Ben Miller's team under the ASP.NET banner and going strong. Most of my work is around MsWebDev and the .NET North West User Group but I hope I'm still giving enough back to the community to warrent being re-awarded the MVP Status.

I had a great time at the MVP Summit 2004 with all of my friends and colleagues - it was great being let in on some of the Microsoft plans for the coming years.

ASP Insiders

The ASP Insiders are growing in strength and "power", as an Influencing body within the ASP.NET community the Insiders are helping out the ASP.NET Team with loads of advice and help and helping out each other with some great help and advice. The Insiders are also helping many component vendors and ISV's by testing their products and offering advice.

At the 2004 summit much fun was had and I spend a great week with the likes of James Shaw, Wally McClure.

Wiley

I'm writing for Wiley on Professional ADO.NET 2.0 with some fantastic co-authors, it's been bloody hard writing though :-)

ASP.NET 2.0

*drool*

VBUG

I've met so many great people through VBUG, this year I've spent time with Graham Parker, Tony Whitter, Dave Sussman, Alex Homer, Mike Taulty, Eamon and many others. Thanks guys, it's been great spending time with you this year.

 

 

Posted: Jan 02 2005, 12:30 PM by Plip | with 1 comment(s)
Filed under:
More Posts