eid
c# development in linux
my pc is linux not windows, i reached in learning to the deployment and publish for asp.net core , i don't know what i should i learn, i found the track is learning iis , but i can't do that in linux , my question :what the .net developer learn instead of iis for linux?
28 replies
yield return
i can't understand the benefits of yield return , if it's benefit to avoid fetching all data from database and storing them in the memory,and reading each data on demand.
i think i can does that by stream types,so what the need to yield return?
23 replies
await-work in thread class is different from await-work in task class?
var thread = new Thread(async () =>
{
Console.WriteLine($"Thread before await: {Thread.CurrentThread.ManagedThreadId}");
await Task.Delay(500); // Simulate asynchronous delay
Console.WriteLine($"Thread after await: {Thread.CurrentThread.ManagedThreadId}");
});
thread.Start();
thread.Join(); // Wait for the thread to complete
// Using Task
Task.Run(async () =>
{
Console.WriteLine($"Task before await: {Thread.CurrentThread.ManagedThreadId}");
await Task.Delay(500); // Simulate asynchronous delay
Console.WriteLine($"Task after await: {Thread.CurrentThread.ManagedThreadId}");
}).Wait(); // Wait for the task to complete
4 replies
✅ CancellationTokenSource .. apply what design pattern?
i notice it's object wrap other object(cancellation-token),to prevent it to set its flag in the background threads,and it is the responsible for manage it(cancel it by set it true,callback method,timeout method,etc),
what the name of that design in c#?
2 replies
svelte with asp.net core
I don't know why svelte not popular with asp.net core, i see it very easy and similar to blazor and overcome on the problem of blazor,
i can't find book that talk about svelte with asp.net core , if u know a book that talk about that , please tell me about it
37 replies
Application.DoEvents method in winform, can't understand it, any one can explain it?
This deadlock, in its general
form – UI waiting for something that is waiting for UI – has existed ever since we started making
UI applications; it predates async-await, it predates .net and C#, it even predates asynchronous
IO in the Windows operating system. And so, unsurprisingly, there is a standard solution for this
problem already built into WinForms (and WPF and all other UI frameworks I know about). This
solution is to let the UI handle events (or “pump messages” in Windows API terminology) while
we are waiting for the background task to complete. In WinForms, we do this by calling the
Application.DoEvents method.
private void button1_Click(object sender, EventArgs ea)
{
var task = DoSomething();
while(!task.IsCompleted)#A
Application.DoEvents();#A
label1.Text = task.Result;
}
private async Task<string> DoSomething()
{
await Task.Delay(500)
return "done";
20 replies
can any one explain that?
Why is functor not an interface?
If both Option and IEnumerable support the Map operation, why are we not capturing
this with an interface? Indeed, it would be nice to do so, but unfortunately, it’s not possible in
C#. To illustrate why, let’s try to define such an interface:
interface Functor<F<>, T>
{
F<R> Map<R>(Func<T, R> f);
}
public struct Option<T> : Functor<Option, T>
{
public Option<R> Map<R>(Func<T, R> f) => // ...
}
This doesn’t compile: we can’t use F<> as a type variable because unlike T, it doesn’t indicate
a type but rather a kind: a type that’s, in turn, parameterized with a generic type. And it’s not
enough for Map to return a Functor. It must return a functor of the same kind as the current
instance
6 replies