Results 1 to 5 of 5

Thread: How to handle shared members of a type in .net?

  1. #1
    Join Date
    Nov 2009
    Posts
    351

    How to handle shared members of a type in .net?

    I am new to the working environment of the visual studio 2010. I am trying to learn the new things in visual studio 2010. Basically I want to know the methods for handling the shared members of type in .net or the best practices for handling the shared member of a type in .net. I will be waiting for the related replies. Thanks in advance.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How to handle shared members of a type in .net?

    Normally the type constructors are also known with the name of type initializers. These constructors are used to initialize the state of a type by initializing the values for the static field or the values for the shared members. This can be done in two ways first one is that if the developer of the application explicitly tries to add a type constructor through the shared keywords or by adding static methods without parameters. Normally the explicit static constructor generates a code which normally performs the worse. I will suggest you to in-place of taking the suggestion at the face value try to dig in the assembley through the disassembler.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Catch the exceptions inside of a type constructor

    While handling the shared member you must have a clear idea about how runtime manages the exception in the constructor. I will try to explain why this is important. See when the exception is thrown run time will search for the nearest catch which can be use to filter the exception. Now what you have to consider is that TypeInitializationException is a fatal error in the application. So you must catch the exceptions inside of a type constructor.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: How to handle shared members of a type in .net?

    According to me you must consider constructor locks while handling the shared members in dot net. Common language infrastructure specifications grantees that a type constructor will only execute one time. This is not the matter if the constructor is explicitly invoked by the user. Now if you are working in the multithreading environment you have to use the locks for synchronizing the threads. The most common problem while using locks is dead locks. So for that you must avoid the static members of another type.

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: How to handle shared members of a type in .net?

    You can not forget the use of static reflection while handling the shared members of a type in dot net. Because reflection gives the developer to construct the tools like objects browsers and it also allows the developer to create extensible applications which has the ability to plug in types at run time. So you must use null references for the instance while you are working with a static property.

Similar Threads

  1. Listing members of Group with >1500 members
    By Umesh Thakur in forum Windows Server Help
    Replies: 11
    Last Post: 03-02-2012, 05:29 AM
  2. Display members of a group with more than 1500 members
    By Simon G in forum Windows Server Help
    Replies: 5
    Last Post: 25-10-2011, 12:35 PM
  3. Replies: 1
    Last Post: 16-08-2010, 05:25 PM
  4. Replies: 1
    Last Post: 16-08-2010, 04:44 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,880,772.60432 seconds with 16 queries