Questions tagged [conceptual]

Conceptual questions involve programming problems which are not related to program code itself, but with algorithm logic and program architecture.

348 questions
212
votes
6 answers

What's the difference between Task.Start/Wait and Async/Await?

I may be missing something but what is the difference between doing: public void MyMethod() { Task t = Task.Factory.StartNew(DoSomethingThatTakesTime); t.Wait(); UpdateLabelToSayItsComplete(); } public async void MyMethod() { var result =…
Jon
  • 35,719
  • 73
  • 218
  • 368
72
votes
12 answers

Post-increment and Pre-increment concept?

I don't understand the concept of postfix and prefix increment or decrement. Can anyone give a better explanation?
Saad Masood
  • 10,178
  • 8
  • 29
  • 39
67
votes
5 answers

Why is TaskScheduler.Current the default TaskScheduler?

The Task Parallel Library is great and I've used it a lot in the past months. However, there's something really bothering me: the fact that TaskScheduler.Current is the default task scheduler, not TaskScheduler.Default. This is absolutely not…
60
votes
4 answers

Abstract Class vs. Interface

I have searched around SO as well as the rest of the web for a good answer but I have't found one that I really understand. I am going to present this in a different way and hopefully the answers will help others as well. As far as I understand,…
nathanjosiah
  • 4,253
  • 4
  • 33
  • 46
36
votes
5 answers

REST API Design: Nested Collection vs. New Root

This question is about optimal REST API design and a problem I'm facing to choose between nested resources and root level collections. To demonstrate the concept, suppose I have collections City, Business, and Employees. A typical API may be…
Alex
  • 71,233
  • 79
  • 245
  • 337
33
votes
4 answers

What is the conceptual difference between SynchronizationContext and TaskScheduler

Stephen Toub blogged that Both SynchronizationContext and TaskScheduler are abstractions that represent a “scheduler”, something that you give some work to, and it determines when and where to run that work. There are many different forms of…
32
votes
11 answers

Real Life Examples For CountDownLatch and CyclicBarrier

One example is given by one of our trainers when he was explaining difference between CountDownLatch and CyclicBarrier. CountDownLatch: Suppose a stone can be lifted by 10 people so you will wait for all 10 to come. Then only you can lift the…
Sunny Gupta
  • 6,219
  • 14
  • 47
  • 80
29
votes
1 answer

What is the difference between SynchronizationContext.Send and SynchronizationContext.Post?

Thanks to Jeremy Miller's good work in Functional Programming For Everyday .NET Development, I have a working command executor that does everything I want it to (do heavy lifting on the thread pool, send results or errors back to the synchronization…
flipdoubt
  • 12,639
  • 13
  • 58
  • 91
27
votes
1 answer

The async and await keywords don't cause additional threads to be created?

I'm confused. How can one or many Task run in parallel on a single thread? My understanding of parallelism is obviously wrong. Bits of MSDN I can't wrap my head around: The async and await keywords don't cause additional threads to be created.…
27
votes
2 answers

Understanding context in C# 5 async/await

Am I correct that async/await itself has nothing to do with concurrency/parallelism and is nothing more than continuation-passing style (CPS) implementation? And the real threading is performed by SynchronizationContext instance that await…
UserControl
  • 13,469
  • 15
  • 88
  • 171
23
votes
3 answers

How to force subclasses to set a variable in java?

I have a class which defines all of the basic parameters for a given screen. From here every screen in the application is a subclass of this. I need every screen (i.e. subclass) to set the value of a variable in its implementation (namely, each…
B T
  • 6,651
  • 11
  • 33
  • 44
22
votes
3 answers

Why aren't method references singleton?

In Java, the following code returns false on both queries. Why? Wouldn't it be simpler for method references to be singleton? It would certainly make attaching and detaching listeners a lot simpler. As it is you need to keep a constant for any…
Dimitriye98
  • 207
  • 2
  • 10
22
votes
3 answers

I/O performance - async vs TPL vs Dataflow vs RX

I have a piece of C# 5.0 code that generates a ton of network and disk I/O. I need to run multiple copies of this code in parallel. Which of the following technologies is likely to give me the best performance: async methods with await directly use…
20
votes
3 answers

Finding items in an universal hash table?

If items are organized randomly, how does the table know where to start looking? In a non-random table items are organized according to some characteristic. (i.e. name). So if the table needs to look up some arbitrary information about "John", it…
fdh
  • 4,922
  • 10
  • 52
  • 97
18
votes
3 answers

Why do we need ContinueWith method?

Why do we need Task.ContinueWith() method. Cannot we just write that "continuation code" inside Task body?
1
2 3
23 24