当前位置:首页
开发技术指南» 文章正文
    引言:

 ·能朗读的电子书籍    »显示摘要«
    摘要: 我想把一篇文章作成能够有声音朗读,可以按照目录搜索的,还可以有点小动画在上面的电子书籍.请问用vb能实现么,怎么实现,大家能帮我下么?我以前没做过这个类型的东西谢谢.解决后一定给分,能帮大忙的给点现金表示也可以滴,我想帮女朋友做个小东西 ......
    摘要: 我用cximage 类想将图片保存成gif bmp jpg 等格式 其他格式都正常 惟有gif 文件超大 速度很慢 请高手指点一下这东西怎么用??? if(strcmp(lpext,"bmp")==0 || strcmp(lpext,"bmp")==0) { if (m_ximage.isvalid()) { m_ximage.sav......


用线程Thread调用Timer时,为什么Timer没有反应,用的是Form下的Timer

//为什么用线程调用timer时,timer不执行  
  //调用另外哪个timer会执行吗?  
   
   
  using   System;  
  using   System.Drawing;  
  using   System.Collections;  
  using   System.ComponentModel;  
  using   System.Windows.Forms;  
  using   System.Threading;  
   
  namespace   MyThread  
  {  
   
  public   class   TestThread  
  {  
  private   System.Windows.Forms.Label   label1;  
  private   System.Windows.Forms.Timer   timer1;  
  private   System.Threading.Thread   timeThread;    
  public   TestThread()  
  {  
  timer1.Tick   +=   new   System.EventHandler(this.timer1_Tick);  
  timer1.Interval   =   100;  
  }  
  private   void   StartTime()  
  {  
  //开始timer,但是没有反应  
  timer1.Start();  
  }  
  private   void   RunThread()  
  {  
  //这里开始线程  
  timeThread   =   new   Thread(new   ThreadStart(StartTime));  
  timeThread.Start();  
  }  
  private   void   timer1_Tick(object   sender,   System.EventArgs   e)  
  {  
  this.label1.Text   =   DateTime.Now.ToString();  
  }  
  }  
  }

NO.1   作者: fanweiwei

先看看timer有没有设置为可用

NO.2   作者: cuike519

System.Windows.Forms.Timer   is   a   forms-based   timer,It   runs   entirely   on   the   UI   thread.  
  So   I   think   you   should   use   System.Timers.Timer   or   System.Threading.Timer.

NO.3   作者: salmon230

同意楼上,加上这句就可以了  
  this.timer1.Enabled   =   true;

NO.4   作者: songhtao

using   System;  
  using   System.Threading;  
   
  class   TimerExampleState    
  {  
        public   int   counter   =   0;  
        public   Timer   tmr;  
  }  
   
  class   App    
  {  
        public   static   void   Main()  
        {  
        TimerExampleState   s   =   new   TimerExampleState();  
   
        //   Create   the   delegate   that   invokes   methods   for   the   timer.  
        TimerCallback   timerDelegate   =   new   TimerCallback(CheckStatus);  
   
        //   Create   a   timer   that   waits   one   second,   then   invokes   every   second.  
        Timer   timer   =   new   Timer(timerDelegate,   s,1000,   1000);  
           
        //   Keep   a   handle   to   the   timer,   so   it   can   be   disposed.  
        s.tmr   =   timer;  
   
        //   The   main   thread   does   nothing   until   the   timer   is   disposed.  
        while(s.tmr   !=   null)  
                    Thread.Sleep(0);  
        Console.WriteLine("Timer   example   done.");  
        }  
        //   The   following   method   is   called   by   the   timers   delegate.  
   
        static   void   CheckStatus(Object   state)  
        {  
        TimerExampleState   s   =(TimerExampleState)state;  
        s.counter++;  
        Console.WriteLine("{0}   Checking   Status   {1}.",DateTime.Now.TimeOfDay,   s.counter);  
        if(s.counter   ==   5)  
              {  
              //   Shorten   the   period.   Wait   10   seconds   to   restart   the   timer.  
              (s.tmr).Change(10000,100);  
              Console.WriteLine("changed...");  
              }  
        if(s.counter   ==   10)  
              {  
              Console.WriteLine("disposing   of   timer...");  
              s.tmr.Dispose();  
              s.tmr   =   null;  
              }  
        }  
  }  
 

NO.5   作者: qpl007

try:  
   
  namespace   MyThread  
  {  
  public   class   TestThread  
  {  
  private   bool   _falg   =   false;  
  private   System.Windows.Forms.Label   label1;  
  private   System.Threading.Thread   timeThread;    
  public   TestThread()  
  {  
  }  
  private   void   RunThread()  
  {  
  //这里开始线程  
  this._flag   =   true;  
  timeThread   =   new   Thread(new   ThreadStart(TestThreadTimer));  
  timeThread.Start();  
  }  
  private   void   StopThread()  
  {  
  this._flag   =   false;  
  if(timeThread.ThreadState   !=   ThreadState.Running)  
  timeThread.Start();  
  timeThread.Abort();  
  }  
  public   void   TestThreadTimer()  
  {  
  while(this._flag)  
  {  
  this.label1.Text   =   DateTime.Now.ToString();  
  System.Threading.Thread.Sleep(500);  
  }  
  }  
  }  
  }  
 


 ·帮忙写一个关于文件夹的代码    »显示摘要«
    摘要: 用什么函数得到所选择文件夹的路径啊?比如说c:/,c:/windows 用一个编辑框,一个按纽,个一个list控件 点按纽出现一个文件选择框,相当于一个cfile,选择后在edit里显示其路径(不是文件的路径,而是文件夹的路径) 怎么实现把该文件夹下的所有文件名(包括子文件夹,比如说选择了c:/那么c:/aa里的文件也要显示出来)在一个list控件里显示啊? 小弟初学,请各位前辈指教 ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE