CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2007
    Posts
    43

    how many instance will a shared variable be created? just 1 correct?

    Hi :
    How many instances of a shared variable will be created in a class? just one? correct
    Code:
    Public Class DocumentDelivery
        Implements IDisposable
    
        'A rendered list that contains the rendered documents
        Public Shared RenderList As List(Of Byte()())
    
    End Class
    So, in other words, the DocumentDelivery class will only have one instance of RenderList, correct? can somebody confirm?

  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: how many instance will a shared variable be created? just 1 correct?

    correct. And all instances of DocumentDelivery (if any) would share it, as any piece of code that can access it through DocumentDelivery (class itself).
    Beware of multithreading on a multiprocessor machine, though: it might ruin your day...
    Last edited by Cimperiali; April 7th, 2010 at 05:57 PM.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Jul 2007
    Posts
    43

    Re: how many instance will a shared variable be created? just 1 correct?

    why? if I never intend for this to run in a multi threaded environment...

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: how many instance will a shared variable be created? just 1 correct?

    then you should have no matters.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured