简体   繁体   English

将多个文件同时保存到 WP7 上的隔离存储

[英]Saving multiple files simultaneously to isolated storage on WP7

I have N number of files to written to isolated storage, is this best done in a sequential manner or can it be asynchronously (eg max 3 in parallel)?我有 N 个要写入隔离存储的文件,最好以顺序方式完成还是可以异步完成(例如最多 3 个并行)?

I know how I do this, I wanted to know if this is a bad idea etc...我知道我是怎么做到的,我想知道这是否是一个坏主意等等......

You can't physically save two files simultaneously.您不能同时物理保存两个文件。 You only have one processor that can only do one thing at a time, and since the file eventually gets written to Flash, which has a controller that can only write one sector at a time anyway, all writes end up serialized at some point.你只有一个处理器,一次只能做一件事,并且由于文件最终被写入 Flash,它有一个 controller 无论如何一次只能写入一个扇区,所有写入最终都会在某个时候序列化。 I'm sure that there's thread safety down in the depths of the file system code that is going to handle multiple write calls just fine, but I don't think you're going to gain any performance by trying to write files in parallel.我确信文件系统代码的深处存在线程安全性,可以很好地处理多个写入调用,但我认为您不会通过尝试并行写入文件来获得任何性能。

Do you have the files in memory, or are you downloading them from somewhere?你有 memory 中的文件,还是从某个地方下载它们? If the files are in memory, then see ctacke's answer.如果文件在 memory 中,请参阅 ctacke 的答案。 If you're downloading them, it might make sense to save them to isolated storage asynchronously rather than wait for each download to complete before starting the next one.如果您正在下载它们,最好将它们异步保存到隔离存储中,而不是等待每次下载完成后再开始下一次下载。 In that case, it really depends on whether they can be downloaded simultaneously.在那种情况下,这实际上取决于它们是否可以同时下载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM