Logo video2dn
  • Сохранить видео с ютуба
  • Категории
    • Музыка
    • Кино и Анимация
    • Автомобили
    • Животные
    • Спорт
    • Путешествия
    • Игры
    • Люди и Блоги
    • Юмор
    • Развлечения
    • Новости и Политика
    • Howto и Стиль
    • Diy своими руками
    • Образование
    • Наука и Технологии
    • Некоммерческие Организации
  • О сайте

Скачать или смотреть Lazy vs Eager loading in Singleton

  • kudvenkat
  • 2017-06-12
  • 178448
Lazy vs Eager loading in Singleton
eager loading singleton c#non lazy singleton c#non lazy loadinglazy keyword in c#thread safe lazy keyword c#how to use Lazy keyword in singleton c#lazy in .net 4.0 framework c#differences between lazy and non lazy initialization c#eager loading advantages c#lazy loading advantages c#singleton pattern lazy c#
  • ok logo

Скачать Lazy vs Eager loading in Singleton бесплатно в качестве 4к (2к / 1080p)

У нас вы можете скачать бесплатно Lazy vs Eager loading in Singleton или посмотреть видео с ютуба в максимальном доступном качестве.

Для скачивания выберите вариант из формы ниже:

  • Информация по загрузке:

Cкачать музыку Lazy vs Eager loading in Singleton бесплатно в формате MP3:

Если иконки загрузки не отобразились, ПОЖАЛУЙСТА, НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если у вас возникли трудности с загрузкой, пожалуйста, свяжитесь с нами по контактам, указанным в нижней части страницы.
Спасибо за использование сервиса video2dn.com

Описание к видео Lazy vs Eager loading in Singleton

Text version of the video
http://csharp-video-tutorials.blogspo...

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
   / @aarvikitchen5572  

Slides
http://csharp-video-tutorials.blogspo...

Design Patterns Tutorial playlist
   • Design Patterns tutorial for beginners  

Design Patterns Text articles and slides
http://csharp-video-tutorials.blogspo...

All Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenka...

All Dot Net and SQL Server Tutorials in Arabic
   / kudvenkatarabic  

In this tutorial we will discuss the difference between Lazy Initialization and Eager Initialization

Lazy Initialization : The lazy initialization of an object improves the performance and avoids unnecessary computation till the point the object is accessed. Further, it reduces the memory footprint during the startup of the program. Reducing the memory print will help faster loading of the application.

Non-Lazy or Eager Loading : Eager loading is nothing but to initialize the required object before it’s being accessed. Which means, we instantiate the object and keep it ready and use it when we need it. This type of initialization is used in lower memory footprints. Also, in eager loading, the common language runtime takes care of the variable initialization and its thread safety. Hence, we don’t need to write any explicit coding for thread safety.

Singleton with Lazy keyword (.NET 4.0) : Lazy keyword provides support for lazy initialization. In order to make a property as lazy, we need to pass the type of object to the lazy keyword which is being lazily initialized.

By default, Lazy[T] objects are thread-safe. In multi-threaded scenarios, the first thread which tries to access the Value property of the lazy object will take care of thread safety when multiple threads are trying to access the Get Instance at the same time.

Therefore, it does not matter which thread initializes the object or if there are any thread race conditions that are trying to access this property.

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SingletonDemo
{
class Program
{
static void Main(string[] args)
{
Parallel.Invoke(
() =] PrintStudentDetails(),
() =] PrintEmployeeDetails()
);
Console.ReadLine();
}

private static void PrintEmployeeDetails()
{
Singleton fromEmployee = Singleton.GetInstance;
fromEmployee.PrintDetails("From Employee");
}

private static void PrintStudentDetails()
{
Singleton fromStudent = Singleton.GetInstance;
fromStudent.PrintDetails("From Student");
}
}
}

Singleton.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SingletonDemo
{

public sealed class Singleton
{
private static int counter = 0;

private Singleton()
{
counter++;
Console.WriteLine("Counter Value " + counter.ToString());
}
private static readonly Lazy[Singleton] instance = new Lazy[Singleton](()=]new Singleton());

public static Singleton GetInstance
{
get
{
return instance.Value;
}
}

public void PrintDetails(string message)
{
Console.WriteLine(message);
}
}
}

Комментарии

Информация по комментариям в разработке

Похожие видео

  • О нас
  • Контакты
  • Отказ от ответственности - Disclaimer
  • Условия использования сайта - TOS
  • Политика конфиденциальности

video2dn Copyright © 2023 - 2025

Контакты для правообладателей [email protected]