Sunday, May 15, 2022

for ref

 what is proxy.conf.ts 


what is @ViewChild and @ViewChildren



What is parallel.ForEach 


What is Plinq


How can we check the query generated by entity framework ? 

What is global assembly cache ? 


What is CLR and CTS ? 


These are parts of a larger specification called CLI (common language infrastructure) 


CLI consists of: 

1. CTS 

2. Metadata (PE files specification - portable executables) 

3. CLS (Common Language Specification)  - common set of  features that every CLI compliant language must expose

4. VES (Virtual Execution System) - CLR 

All the CLI compliant languages are statically compiled to CIL (Common Intermediate Language) code 

CLR JIT compiles CIL to native code, caches the code and executes it. 

High Level Code to CIL -> static compilation  (generates dlls , 

or if Portable options is selected generates PE file for 32 bit, PE+ for 64 bit)

CIL to native code -> JIT compilation by CLR

AOT compiler-> translate IL to machine code -> can better optimize code

JIT compiler ->  translate IL to machine code 

There are two versions of CLR : CLR and CoreCLR. CoreCLR can JIT for targets such as Windows, linux and macOS.

CLR Handles memeory management and garbage collection. 


Which are the languages supported by CLI/CLR ? 

C#, VB.NET , Python/PASCAL ports are also available.



Which are the types supported by CTS ? 

Classes

Structures

Enumeration

Interfaces

Delegates


Are delegates type  safe than a function pointer ? how ? 

Delegates are guranteed to be refer to  a valid method with correct signature, a pointer can mistakenly be assigned to something else also. 

Secondly delegates can bind to a method of an object , rather than a class. 



The type double in C# is a floating point type. How do classify C# numeric types 

in floating and fixed point types ? 



Is EntityFramework (or Dbcontext) thread safe ? 

No. EF /DbContext are safe only when each thread uses separate Dbcontext. 

So if you are using DbContext in Parallel.ForEach loop, better to instantiate 

a new DbContext on every iteration. 

=============================================================================

https://www.codemag.com/article/1407051/Python-for-C#Back2article

Python for C# Developers  By Michael Kennedy 

A very important article comparing features of Python and C#


https://www.red-gate.com/simple-talk/development/dotnet-development/10-reasons-python-better-than-c-sharp/

10 reasons why Python is better than C# (or almost any other programming language)

By Andy Brown

=============================================================================

What is Task Parallel Library ? 

Most of the desktops/laptops in today's scenario use multicore CPUs. 

The true adavantage of multicore CPUs can only be taken when the we can run 

tasks simultaneously on multiple cores. 

C# provides parallel computing through TPL. 

TPL provides two types of parallelism : 

Data Parallelism : 

Parallel.For method 

Parallel,ForEach method

Task Parallelism: 

Parallel.Invoke


What types of tasks can be executed parallely ? 

For parallel execution : 

Tasks should be independent of each other. 

Order of execution should not matter


What is the difference between standard For loop and Parallel.For loop ? 

1. Standard for loop executes in a single thread where as Parallel.For loop executes in multiple threads

2.Standard for loop executes in sequential order but Paralllel.For loop will not execute in order. 



Parallel is a static class with static For, ForEach and Invoke methods. 


 public static ParallelLoopResult For(int fromInclusive, int toExclusive, Action<int> body);

NOTE that the first parameter is  Inclusive and  end parameter is Exclusive. 



How do you control the degree of parallelism in Parallel.For loop ? 


By using MaxDegreeOf Parallelism. 


We can pass a ParallelOptions parameter to Parallel.For loop as third parameter. 

In this ParallelOptions object we can set MaxDegreeOfParalllism: 


var options = new ParallelOptions (){ 

MaxDegreeOfParallelism = 2 


Parallel.For( 0, 100 , options, x=> {} );


If MaxDegreeOfParallelism is set to -1, then there is no limit on the number of concurrently running tasks.


How to limit MaxDegreeOfParallelism to use maximum 75% of resources ? 

int NoOfCoresPerProcessor = 2;

new ParallelOptions

{

    MaxDegreeOfParallelism = Convert.ToInt32(Math.Ceiling((Environment.ProcessorCount * 0.75) * NoOfCoresPerProcessor ))

};


ParallelLoopState.Stop and ParallelLoopState.Break methods 

In Break: 

all the previous iterations are completed (index < LowestBreakIteration) 

all the higher index iterations will exit at their convenience

In Stop: 

all iterations will exit at thier convenience


What is the difference between parallelism and concurrency ? 

In concurrency, tasks take turn for execution. So if tasks T1 and T2 

are executing, when T1 executes, T2 waits for its turn and vice versa. 

But in parallelism, both tasks execute at same time. 



How to determine if the parallel loop is complete ? 

By using ParallelLoopResult.IsCompleted flag. 

Console.WriteLine("IsCompleted: {0}", parallelLoopResult.IsCompleted);


Potential pitfalls : 

https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/potential-pitfalls-in-data-and-task-parallelism


===================================================================

Blockchain C# 

https://www.c-sharpcorner.com/article/building-a-blockchain-in-net-core-p2p-network/

Building A Blockchain In .NET Core - P2P Network

Henry He

===================================================================

http://dotnetpattern.com/top-linq-interview-questions

code with mukesh 

C# Corner  sarathlal saseendran

===================================================================

Repository and dapper 

http://www.mukeshkumar.net/articles/web-api/dapper-and-repository-pattern-in-web-api

https://cpratt.co/truly-generic-repository-2/

https://www.c-sharpcorner.com/article/implement-unit-of-work-and-generic-repository-pattern-in-a-web-api-net-core-pro/

https://www.c-sharpcorner.com/article/implement-unit-of-work-and-generic-repository-pattern-in-a-web-api-net-core-pro/

====================================================================

How do put a cap on the maximum size of a file that can be uploaded in a WEB API using multiplart mime type ? 
services.Configure<FormOptions>(options => { // Set the limit to 256 MB options.MultipartBodyLengthLimit = 268435456; });

No comments:

Post a Comment

 using Microsoft.AspNetCore.Mvc; using System.Xml.Linq; using System.Xml.XPath; //<table class="common-table medium js-table js-stre...