Assembly.GetManifestResourceStream(name) 在每次调用时都会返回一个新流吗?

发布于 2024-12-09 03:32:17 字数 188 浏览 3 评论 0原文

文档 GetManifestResourceStream 不清楚对同一资源的多次调用。每次调用都保证一个独立的流实例吗?

原因:知道是否应该担心并发使用。

The documentation GetManifestResourceStream is not clear about multiple calls for the same resource. Does each call guarantee an independent stream instance?

Reason: know if one should worry about concurrent use.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

独自←快乐 2024-12-16 03:32:17
internal unsafe Stream GetManifestResourceStream(string name, ref StackCrawlMark stackMark, bool skipSecurityCheck)
{
    // blahblah
    //...
    return new UnmanagedMemoryStream(pointer, (long) length, (long) length, FileAccess.Read, true);
}

所以,是的。如果没有的话就很难使用了。

internal unsafe Stream GetManifestResourceStream(string name, ref StackCrawlMark stackMark, bool skipSecurityCheck)
{
    // blahblah
    //...
    return new UnmanagedMemoryStream(pointer, (long) length, (long) length, FileAccess.Read, true);
}

So, yes. It would be quite hard to use if it didn't.

不羁少年 2024-12-16 03:32:17

鉴于流是有状态的,如果两个调用收到相同的 Stream 引用,我会感到非常惊讶。听到两个流都可以是同一位内存的视图,但应该对调用者隐藏,我不会感到惊讶。

我认为假设流是独立的是合理的。

Given that streams are stateful, I would be highly surprised if two calls received the same Stream reference. It would surprise me much less to hear that two streams could both be views onto the same bit of memory, but that should be hidden from the caller.

I think it's reasonable to assume that the streams are independent.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文