Exemplo n.º 1
0
    private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
    {
        //double speed = e.BytesReceived / 1024d / sw.Elapsed.TotalSeconds;
        //string speedStr = string.Format("{0} kb/s", (e.BytesReceived / 1024d / sw.Elapsed.TotalSeconds).ToString("0.00"));

        int         value = e.ProgressPercentage;
        NewNotiData ndata = new NewNotiData(DownLoadState.Progress, value);

        if (func != null)
        {
            func(ndata);
        }

        //if (m_SyncEvent != null)
        //    m_SyncEvent(ndata);

        if (e.ProgressPercentage == 100 && e.BytesReceived == e.TotalBytesToReceive)
        {
            sw.Reset();
            ndata = new NewNotiData(DownLoadState.Done, currDownFile);

            if (func != null)
            {
                func(ndata);
            }

            //if (m_SyncEvent != null)
            //    m_SyncEvent(ndata);
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 线程完成
    /// </summary>
    /// <param name="data"></param>
    void OnThreadCompleted(NewNotiData data)
    {
        switch (data.evState)
        {
        case DownLoadState.Progress:     //进度
            //Debug.Log("进度" + data.evParam);
            break;

        case DownLoadState.Done:     //下载一个完成
            downloadFiles.Add(data.evParam.ToString());
            Debug.Log("下载完成" + data.evParam);
            break;
        }
    }