pick a number from 1 to 10

  • Thread starter Thread starter rodchar
  • Start date Start date
Peter Duniho said:
J.B. Moreno said:
And nothing would guarantee it if it was a WinForm application deployed
to a Windows 2008 server. [...]

That depends on the deployment. But if the deployment is specifically
some sort of server context where something outside the C# program is
somehow creating the potential for multiple processes, then the answer
to that question is STILL outside the scope of this newsgroup.

He wants to solve a problem, he wants to solve that problem using C#.
Unless the scope of the newsgroup is limited to just questions about
syntax, it's well within the scope of the group.

The OP asked "how do i manage users picking the same number?" -- he is
asking guidance for methodology, no different than asking what design
pattern to use.

He should be told that there are two possibilities: either an error
message when submitting a choice that has already been picked, or
blocking other users from making a choice while giving a particular
user a chance/timeframe to make a decision from the available options.

I am *certain* that you could write a class/interface for doing either
possibility that in no way relied upon the internal workings of
ASP.NET.
 
I am *certain* that you could write a class/interface for doing either
possibility that in no way relied upon the internal workings of
ASP.NET.


Yes, you are correct and Peter Dumbo is wrong, as often the case.
Peter is very brittle and often breaks. But he is useful, and I
appreciate his posts, so don't get me wrong.

A singleton indeed is a kludgy but practical design pattern for this
problem.

RL
 
J.B. Moreno said:
[...]
I am *certain* that you could write a class/interface for doing either
possibility that in no way relied upon the internal workings of
ASP.NET.

I amused that so far, no one has bothered to do so.

Please, show us the code that can be used in an ASP.NET project to
address the specific question, and which works regardless of whether
it's in an ASP.NET project at all, never mind how that ASP.NET project
is deployed.

Pete
 
You also have to define what is "at the same time". Would it be like a book
you borrow, it is 'picked' as long as the borrower does not give it back?
or would it mean something like "in the same interval of time of some clock
tic" (ie. it is ok for two users to take number 2 as long as they do it not
at the same clock tic). I assume it is possible to have a common
centralized 'registry' (database, like, easier to share between many than
memory (buffer) assigned to a 'standard' process), else I fail to see who
can access the relevant history. The solution also depends on what you want
to do? simply DETECT the contention? if so, the first case can be solve if
you keep the history of in-s and out-s for each item (or the whole history),
and in the second case, the same, but force a check-in (terminate all
pending 'choices' that have not checked-out yet) at the start of each of
your clock tic (which I assume is still large enough to allow your code to
execute many operations).

But overall, the problem is quite fuzzy.

Vanderghast, Access MVP
 
Sure they are. The mere fact that it's an ASP.NET application guarantees
that.

No.

The same concurrency issues exist in non-ASP.NET contexts.

That makes it non-ASP.NET specific.
In a C# program, the solution is trivial.

No.

It is only trivial in a C# desktop app.

It is non trivial in all server contexts no matter whether
it is a ASP.NET web app or a WCF web service or Windows
service acting as socket server or a console app
acting as socket server.
But in ASP.NET, there's no
guarantee AFAIK that every client being serviced is being handled by the
same process.

True.

But there are no guarantee in any other context except the most trivial.

And C# is more than desktop apps.
If nothing else, the fact there's no way for someone unfamiliar with
ASP.NET to know for sure that every client is being serviced by the same
process makes the question ASP.NET-specific, even if the answer turns
out to be the same.

Any programmer above beginner level would consider this a problem
best handled in the BLL completely unrelated to the choice of PL.

Making ASP.NET as PL completely irrelevant.

Arne
 
Would clustering result in multiple processes being handled by multiple
processes?

Yes. That would mean different processes on different systems.
If so, I _really_ am boggled by your assertion that the
concurrency issues are not ASP.NET-specific.

I believe that you are boggled.

But clustering is not an ASP.NET specific concept.

Arne
 
J.B. Moreno said:
And nothing would guarantee it if it was a WinForm application deployed
to a Windows 2008 server. [...]

That depends on the deployment. But if the deployment is specifically
some sort of server context where something outside the C# program is
somehow creating the potential for multiple processes, then the answer
to that question is STILL outside the scope of this newsgroup.

No.

Server side programming is on topic here.
Because the OP is using ASP.NET, I suggested the ASP.NET newsgroup. That
is a newsgroup where server issues are very much on-topic while still
being specifically connected to the actual API the OP is using, and the
OP will find much greater expertise than here.

He will most likely be told that it is off topic there, because it
has nothing to do with ASP.NET.
You may want to argue that the OP would be even better served by a forum
that is even more specifically about deploying server-side
implementations than the ASP.NET newsgroup. That seems like a fine
point, and it might be true. But there's no justification at all for
suggesting that the topic has anything to do with C# specifically, and
even suggesting it's a normal .NET topic is a stretch.

Given that he wants to actually wants to implement this code in C#
I would consider it on topic.

Otherwise it would be a very low traffic group.

Arne
 
J.B. Moreno said:
[...]
I am *certain* that you could write a class/interface for doing either
possibility that in no way relied upon the internal workings of
ASP.NET.

I amused that so far, no one has bothered to do so.

Please, show us the code that can be used in an ASP.NET project to
address the specific question, and which works regardless of whether
it's in an ASP.NET project at all, never mind how that ASP.NET project
is deployed.

Two methods has been proposed:
* single node using ordinary memory synchronization
* multinode using database

Are you saying that you can not implement those without
referencing anything ASP.NET ??????????

Arne
 
Arne said:
Two methods has been proposed:
* single node using ordinary memory synchronization

Works only in-proc and does not deal with a multi-proc scenario (which
is possible for an ASP.NET project).
* multinode using database

That's true…I forgot it had been mentioned. But it's not the kind of
thing someone NOT doing this in the context of ASP.NET would choose.

Anyway, I know your habits…you can't let this go, and you will swear up
and down until the cows come home that the OP doesn't have an ASP.NET
question. Fine by me. I won't agree, but I'll stop trying to convince
you otherwise (as if there had ever been any chance of doing so in the
first place).

Pete
 
Back
Top