English 中文(简体)
在利用背景阅读时有效显示档案状况
原标题:Efficiently display file status when using background thread

在使用背景线索时如何有效地展示档案状况?

例如,请允许我说,我有100个德国马克档案:

如下文法(作为实例加以解释)在大约1分钟内施行:

foreach(byte b in file.bytes)
{
   WriteByte(b, xxx);
}

但是,如果想向用户提供最新信息,即必须利用代表从主线上更新国际交易日志,则以下代码即刻字不提等待多久,造成这一职位,甚至30%。

int total = file.length;
int current = 0;
foreach(byte b in file.bytes)
{
   current++;
   UpdateCurrentFileStatus(current, total);
   WriteByte(b, xxx);
}

public delegate void UpdateCurrentFileStatus(int cur, int total);
public void UpdateCurrentFileStatus(int cur, int total)
{
        // Check if invoke required, if so create instance of delegate
        // the update the UI

        if(this.InvokeRequired)
        {

        }
        else
        {
          UpdateUI(...)
        }
}
最佳回答

我建议你根据过去时间进行更新,以便你不论文件大小或系统负荷,都能有可预测的更新间隔:

    DateTime start = DateTime.Now;
    foreach (byte b in file.bytes)
    {
        if ((DateTime.Now - start).TotalMilliseconds >= 200)
        {
            UpdateCurrentFileStatus(current, total);
            start = DateTime.Now;
        }
    }
问题回答

逐年向金融情报中心提供最新信息。 仅每100克更新一次。

观察:

int total = file.length;
int current = 0;
foreach(byte b in file.bytes)
{
   current++;
   if (current % 100000 == 0)
   {
        UpdateCurrentFileStatus(current, total);
   }
   WriteByte(b, xxx);
}

您经常更新该调查,每份1亿德国马克的档案将每份更新1亿德国马克(每份对国际调查组的校对)。

详情见档案总尺寸的百分比,可能为10%甚至5%。 因此,如果档案尺寸为100个字塔,则在10个、20个、30个等方面更新情报分析股。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签