473,804 Members | 3,771 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

asyncronous method call

I'm inside a function where I have a static cache, when the cache needs to
be updated I want to do it asyncronously, because updating the cache takes a
while. I want to use thread safety when writing and reading the cache (a
Mutex?)

Private Function Count(ByVal Guid)As Int32
Static Dim countResults As Hashtable = New Hashtable
Static Dim countResultTime stamps As Hashtable = New Hashtable
'Here I want to call CacheUpdateCoun t(countResults,
countResultTime stamps, Guid) in a new asyncronous thread updating the static
cache
Return countResults(Gu id)
End function

Private Function CacheUpdateCoun t(ByRef countResults As Hashtable, ByRef
countResultTime stamps As Hashtable, ByVal Guid)
'Update static cache
end function

1 ) How do I spawn a new thread calling the CacheUpdateCoun t() method?
2) How do I ensure that I don't read and write the cache at the same time?

Kind Regards,
Allan Ebdrup
Nov 17 '05 #1
1 2191

"Allan Ebdrup" <co****@ofir.co m> wrote in message
news:OR******** ******@tk2msftn gp13.phx.gbl...
I'm inside a function where I have a static cache, when the cache needs to
be updated I want to do it asyncronously, because updating the cache takes
a while. I want to use thread safety when writing and reading the cache (a
Mutex?)

Private Function Count(ByVal Guid)As Int32
Static Dim countResults As Hashtable = New Hashtable
Static Dim countResultTime stamps As Hashtable = New Hashtable
'Here I want to call CacheUpdateCoun t(countResults,
countResultTime stamps, Guid) in a new asyncronous thread updating the
static cache
Return countResults(Gu id)
End function

Private Function CacheUpdateCoun t(ByRef countResults As Hashtable, ByRef
countResultTime stamps As Hashtable, ByVal Guid)
'Update static cache
end function

1 ) How do I spawn a new thread calling the CacheUpdateCoun t() method?
2) How do I ensure that I don't read and write the cache at the same time?

Kind Regards,
Allan Ebdrup


Please post VB related questions to the microsoft.publi c.dotnet.langua ges.vb
NG.

Willy.
Nov 17 '05 #2

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

Similar topics

0
1341
by: Ivar | last post by:
Hi, Is SocketOptionName.ReciveTimeout usable with asyncronous socket methods ? With Recive method it works but BeginRecive can't get it working.
1
1221
by: Nathan | last post by:
On my .NET web project I am trying to make an asyncronous call to a function using IAsyncResult. The function will process for about a 1/2 hour. before it completes, the process abruptly ends as though it has timed out. I'm not sure what is timing out. Would it be the page I am making the async call from? Or possibly the connection/command objects I am using to connect to my sql db?
0
1024
by: Paul Fi | last post by:
what is the point of asyncronously processing requests or responses at channel sinks when we can do asyncronous calls at the .net remoting application level ? do we consider AsyncProcessResponse method of the IClientChannelSink class as a callback function? how is async calls differ from having threads controling my calls?
1
4468
by: il RicercatoreSbadato | last post by:
title: asyncronous Socket and EndAccept() question: hi to all, I am working with a server that uses the sockets in a asyncronous way. When I want to STOP the server I do the following: - serverMainSocket.EndAccept(); - serverMainSocket.Shutdown(SocketShutdown.Both); - serverMainSocket.Close(); My problem is on the first instruction. I don't know what can I put as argument in the EndAccept().
3
1054
by: Pug Fugly | last post by:
I have been using asynchronous threading to handle the button actions on my form (the ones that need to make database calls anyways). I am curious if anyone has found a way to make the calls more generic? Is it possible to structure the code so that you don't have to create the delegate, BeginAction(), EndAction(), and ActionCallback() functions for every single action that I want to handle? Especially since the only thing different...
4
2134
by: aaronwmail-usenet | last post by:
Hi. I'm working on a project where a javascript program will get into the middle of some very complicated operation and then decide it needs to use to download an xml file from a server. Because it's in the middle of something potentially complicated I need to down the file synchronously (without interrupting the flow of control), but I'd like to make sure that the browser doesn't freeze up.
1
1231
by: Josema | last post by:
Hi, I made an application that foreach directory that found in the hardisk create a node into a treeview. Of course, to avoid that the user interface gets blocked, i use a handler in a syncronous way. The problem is that when i execute the application and click a button to fill the treeview, dont fill anything.
2
1995
by: Joe | last post by:
Hello All: I have an executable that makes several asynchronous calls to a web service. The executable increments a counter for each async Web service call and decrements the counter whenever the call returns. When the counter == 0 (i.e. all calls have returned), I do some clean up and close down the executable. What if all of the calls don't return? What can I do if five async calls are made and four come back. My current app...
3
1733
by: OJ | last post by:
Hi, I have written a small C# 2.0 DLL which acts as a client to a Socket based server over the internet. I have written both synchronous and asynchronous methods to connect, send, and receive data from the server. Each request/response can take upto 180 seconds. I am trying to use the asyncronous calls in an ASP.NET C# 2.0 Webcontrol, which displays the returned data. At the moment I am happily using the asyncronous functions and events...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10337
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9160
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.