.NETGURU
Solid ASP.NET Threading examples?
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngvb' list.


Walter Quesada
-- Moved from [aspngfreeforall] to [aspngvb] by Tim Musschoot <Click here to reveal e-mail address> --

I can't for the life of me find any solid ASP.NET multithreading examples, everything is Windows Forms in C# which I tried to recreate on web forms, but to no success. Anybody out there have any solid asp.net multithreading (System.Threading) examples?

What I am basically trying to do is create a background process (in dll file) launched by a web form's button onclick event ... I want the user to click the button and get a response under a second saying they will be notified via email when the process has been completed.

Your help is greatly appreciated!!

Walter

PS: Here's a little something I modified that I found in MSDN, it's not working for me though. The page runs fine, but after the alloted time frame, nothing happens (running Test.OnNewThread), the XML file never gets updated. If I run the same script without the threading (directly running App.Main), the XML file does indeed get updated, so I am sure it has something to do with the threading, let me know what you think ...

Imports System
Imports System.Xml
Imports System.Threading
Namespace Test
Class TimerExampleState
Public counter As Integer = 0
Public tmr As Timer
End Class
Public Class OnNewThread
Public Shared Sub Start()
Dim oThreadExample As New App()
Dim oThreadStart As New ThreadStart(AddressOf oThreadExample.Main)
Dim oThread As New Thread(oThreadStart)
oThread.Start
End Sub
End Class
Public Class App
Public Shared Sub Main()
Dim s As New TimerExampleState()
Dim timerDelegate As New TimerCallback(AddressOf CheckStatus)
Dim timer As New Timer(timerDelegate, s, 240000, 1000)
s.tmr = timer
While Not (s.tmr Is Nothing)
Thread.Sleep(0)
End While
WriteXmlTest()
End Sub
Shared Sub CheckStatus(state As [Object])
Dim s As TimerExampleState = CType(state, TimerExampleState)
s.counter += 1
If s.counter = 5 Then
s.tmr.Change(10000, 100)
End If
If s.counter = 10 Then
s.tmr.Dispose()
s.tmr = Nothing
End If
End Sub
Public Shared Sub WriteXmlTest()
Dim strXml As String = "mytestxmlfile"
Dim objXML As XmlDocument = New XmlDocument()
objXML.Load(strXML)
Dim objTests As XmlNode = objXML.SelectSingleNode("tests")
Dim objTest As XmlElement = objXML.createElement("test")
Dim objDate As XmlAttribute = objXML.CreateAttribute("date")
objDate.Value = DateTime.Now()
objTest.SetAttributeNode(objDate)
objDate = Nothing
Dim objUid As XmlAttribute = objXML.CreateAttribute("msg")
objUid.Value = "MultiThread Testing!"
objTest.SetAttributeNode(objUid)
objUid = Nothing
objTests.appendChild (objTest)
objXML.Save(strXML)
objTest = Nothing
objTests = Nothing
objXML = Nothing
End Sub
End Class
End Namespace

Reply to this message...
 
    
Richard Purchas
Check the presentations out at: http://www.sdnug.org. I think there's one
(with source) on using threading.

[Original message clipped]

Reply to this message...
 
    
Bob Macleod
Please be a bit more specific. The reference below does not lead cleanly to
any information on using threading. Thanks

[Original message clipped]

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com

Reply to this message...
 
 
System.DateTime
System.Threading.Thread
System.Threading.ThreadStart
System.Threading.TimerCallback
System.Xml.XmlAttribute
System.Xml.XmlDocument
System.Xml.XmlElement
System.Xml.XmlNode




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification