C#: How do I wait 10 seconds for a client to call a method? [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
On a server(Web API), I have methods A and B. When method A reaches a certain point it uses SignalR to call a client method with a certain ID and then has to wait 10 seconds. If a client calls web method B with that ID within those 10 seconds then method A enters Path 1. If a client does not call method B then method A enters Path 2. Do you have any ideas on how to implement that?
Thank you,
Peter Chikov

HTTP is designed to be stateless. If possible, the server should not be attempting to keep track of the client's state. Can you change your implementation so that the client initiates a new request after the SignalR call and then enters path #1 or #2?

Related

What is the Best/preferred way of Queuing any Request in C# for Web API built on .Net 6 | C# synchronous process implementation [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 days ago.
This post was edited and submitted for review 3 days ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
Issue:
Queue the multiple requests for printing 1 at the time for given printer.
this approach is not working https://michaelscodingspot.com/c-job-queues/
as while adding request in thread it will loose the this.DBContext object.
Explanation:
There are multiple terminals/clients pc to call WEB API built on .net-6.0 which triggered the code which is responsible for printing to execute and send out the print command with object to be printed to Printer. As there are many printers are available but if any one printer is in use means If one request is printing on 1 printer then other request should not proceeds and wait till first request will finish printing and then it will take another request and process for printing like this, flow continues.
Please see below diagram.
Which is the best way to handle such scenario without using any third party DDL or any DB save of all requests and triggered it from there.
Flow

What is my best option for running an Azure Durable Functions Activity 1 hour in the future? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 days ago.
Improve this question
I have an orchestration which interacts with a third party API. My orchestration submits something to the third party API and then has to wait an hour before asking the third party API for data related to the first submission.
What is the best way to "wait" for the hour:
a. Add a Task.Delay(TimeSpan.FromHours(1)) to an Activity function, or
b. Use IDurableOrchestrationContext.CreateTimer() and wait for it to fire, or
c. Create a Durable Entity and use the scheduledTimeUtc parameter of a SignalEntity() call?

Thread State Management in Asynchronous Programming [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am new to asynchronous programming in .Net using C#. All I have understood so far is :
With asynchronous programming, threads that are waiting for a web service or database to return data are freed up to service new requests until the data the is received.
Once the data is received, the thread is restarted and continue processing the code that comes after that call.
Now , I wanted to know in details How the state is managed for the thread so that it can start executing from the point the async call was made.
If it uses a stack to handle that, Can some one please give me an insight into the process?
Thanks,
Mayank
Now , I wanted to know in details How the state is managed for the thread so that it can start executing from the point the async call was made.
Async method are divided into smaller chunks. Basically, when compiling async method, for every await keyword new method is generated.
Keep in mind, that this is a big simplification and it's all done behind the scenes and you really don't need to know how it works in order to use it.

What is the effect of timer control on IIS when used in .net web service [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to know that What is the effect of timer control on IIS when used in .net web service. i.e. how much increase in the resource consumption of W3WP process.
You shouldn't use timers in a Web service. Since HTTP is stateless, you're serving resources and closing the whole connection with the client in a few milliseconds. That is, you don't want long processes since you want to prioritize more concurrent requests than long requests.
If you need to perform background processing, you should use a Windows service.
Take a look at Topshelf documentation to get started with Windows service development.

c# notify a running process [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Is it possible to somehow notify a running process from the "outside"?
I have a C# program that theoretical runs forever. And I would like to notify it to trigger some action manually. It would be best, if this solution is possible on Windows and Linux (mono).
EDIT:
The solution should work without a user interface
My program is, as for now, a part of web service. On initializing, a new Theread is created, which uses the Task class to stay alive
Take your forever-running-process and let it provide a webservice other processes can call.
You might use any cross-plattform webservice framework like WebApi or ServiceStack to achieve this via HTTP calls. This will even work over the internet (if the machines can reach each other).
There are dozens of approaches. You could also use named pipes for example, or put commands into a database (the other process has to query regularly) or - if you're fearless enough - write/read files to communicate. Be creative ...

Categories

Resources