IRandomAccessStream CloneStream under the hood RRS feed

  • Question

  • Hi there,

    I'm currently working on a project in which I have multiple threads reading from one file. Each thread has a reference to an IRandomAccessStream which they use for reading from the file. Currently, when I create a new thread, it just creates another reference to the stream.

    Like this:

    IRandomAccessStream^ stream2 = stream1; // stream 1 is already an IRandomAccessStream

    I'm considering using clone stream instead.

    Like this:

    IRandomAccessStream^ stream2 = stream1->CloneStream(); // stream 1 is already an IRandomAccessStream

    Exactly what is the difference between the two. Will stream1 and stream2 have to wait for each other, even though I've used the cloned function. What type of speedup can I expect if I repeatedly access the file in different locations with the different threads (even more than 2).

    Thanks in advance for answers, and let me know if I should clarify anything.

    Tuesday, November 27, 2012 2:19 AM


  • Hi,

    I think, in the first way, it passes a reference of stream1. If the stream1 changed, the steam2 should be changed.

    The CloneStream function will creates a new instance of a IRandomAccessStream over the same resource as the current stream.

    Best regards,

    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Jesse Jiang Tuesday, December 4, 2012 2:23 AM
    Wednesday, November 28, 2012 10:57 AM