It appears that System.Random would provide an acceptable means through
which to generate a unique value used to identify multiple/concurrent
asynchronous tasks.
The usage of the value under consideration here is that it is supplied to
the AsyncOperationM anager.CreateOp eration(userSup pliedState) method... with
userSuppliedSta te being, more or less, a taskId.
In this case, the userSuppliedSta te {really taskId} is of the object type,
and could therefore be just about anything. Consequently it appears to me
that a unique integer as generated by System.Random would suffice (and yes,
I understand that System.Random doesn't provide *truly* random values).
Would you concur that System.Random would be "good enough" - or would you
recommend some better alternative for generating the taskId?
Thanks!
Sep 14 '07
10 4508
Frankie wrote:
<snip all>
Thanks for the helpful dialog on this. I learned a lot as this was my
initial encounter with the Event-based async pattern and the MSDN sample is
what I was basing everything off of. And thanks especially for posting some
very clear feedback and perspective on how you would modify the MSDN sample
in a way that frees the client from having to come up with some arbitrary
ID.
You're welcome. As you can see, it is often much easier to offer
comments when there is a concrete example of code to start with
(especially if that code sample is relatively minimal).
I didn't really like it to begin with, and especially their use of
Random... thus the OP here.
Indeed. I hope if nothing else it's clear that using Random isn't
appropriate for generating task IDs. Note, however, that the use of
Random in the sample code isn't for the task ID, but rather for the
number to test for prime-ness. The sample code uses a GUID as the task ID.
So, while there are obviously aspects of the sample I would do
differently, it's not actually broken. :)
Pete This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Christopher Weaver |
last post by:
I want to set a value in a specific field in the current row of a DataSet.
This seems like the most basic thing to do but I can't find the syntax for
identifying the current row.
IOW, I can do this:
SomeRow = 'value';
But how do I set SomeRow to the row that the user is currently viewing?
|
by: milesm |
last post by:
I've spent the last 3 hours reading various MSDN articles, other site
articles and news group postings and was wondering what the best approach to
my situation would be since I'm unable to come up with the best approach.
What's Needed........
1. Various background SQL inserts that don't interrupt the client
request/response
2. Various background emails generated and sent that are separate from the
client request/response
3. Every...
|
by: Alan Silver |
last post by:
Hello,
After much battling, I think I am finally seeing some progress on my
first user control (thanks to the patient souls who have answered my
many questions!!). I am left with one more problem though...
As detailed elsewhere, I have identified the need to use the ViewState
to hold a flag that indicates whether or not this is the first time the
control is loaded (ie if the flag isn't in the ViewState then it's the
first time,...
|
by: Jeremy |
last post by:
I have a core VB service that monitors a database, and based on data in the
records will execute code to send email notifications.
Problem:
I don't want my main program code to halt and wait for this execution... we
need immediate execution of all notification processes and would prefer to
spawn multiple instances generating emails at one time.
Solution ?
I took a look at threading, and at first it looked to be the answer.
|
by: jasonsgeiger |
last post by:
From: "Factor" <jasonsgeiger@gmail.com>
Newsgroups: microsoft.public.in.csharp
Subject: Multiple Clients, One port
Date: Wed, 19 Apr 2006 09:36:02 -0700
I'm been working with sockets for a short while now using a server
program a former coworker started. The program listens on a port for
incomming connections. When a valid connection is made (we send this
init string into the socket from the clients) the server closes the
socket so...
| |
by: jonathan |
last post by:
I need to create a webpage that asynchronously loads a series of user
controls onto a page.
If the user control take longer than X seconds to load it should
display an error message in it place. The rest of the page should
continue to load whilst the seperate user control threads are loading.
What is the correct way of doing this?
I've created a delegate for loading the user control sand called
|
by: Logan1337 |
last post by:
Hello, I'm writing a shareware app that needs to be unlocked with a serial number key. I want the key to be encrypted (that is, digitally signed) such that the app can verify that it was generated by me and no one else.
I also want to include information that ties the key directly to the computer it was purchased for. I have been exploring various ways to do this, but want to know if anyone has any tips/advice for doing this.
So far I have...
|
by: jaffarkazi |
last post by:
Hi
I have a page that is going to send a number of emails that will be
fetched from the database. This is on a hosted server, so I don't have
any background automatic way of sending mail. (If anyone can make a
suggestion for this, that would be good too).
There may be 2 mails or 100 mails. I'm not particularly interested
that the page will timeout or not.
The tasks will basically be:
1. Pick up the emails from the database.
|
by: raylopez99 |
last post by:
A quick sanity check, and I think I am correct, but just to make
sure: if you have a bunch of objects that are very much like one
another you can uniquely track them simply by using an ArrayList or
Array, correct? An example: create the object, create an array, the
stuff the object into the array. Later on, assume the object is
mutable, the object changes, but you can find it, if you have enough
state information to uniquely identify...
|
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...
|
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,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |