当前位置:首页 » 软件开发
开发技术指南» 文章正文
    引言: 单例模式用于限制进程中只有一个某个类的对象,本例的Singleton是一个线程实例,在每一个时钟到达时检测是否到达某个时刻(本例的时刻存于Ini文件中),如果到达则产生一个线程,但是如果在这个线程完成其任务前又到达一个时钟,则有可能会产生多个线程执行任务,以致出现混乱,所以考虑使用Single...
 

 

    摘要: 之前用的是java那一套东西,有eclipse什么都搞定了。现在因为要用delphi改一个即时通讯软件的缘故,想着怎么能把重构和单元测试那一套搬到delphi这边来。书上说给现有的代码加单元测试能够加深对代码的理解,并且可以作为改善代码的基础,这不正是我要做的事情吗?于是,为了搭建这么一个敏捷平台,我以delphi2005和dunit进行了一点小小的尝试,并把结果记录于下,与大家分享。 1、下载......
    摘要: //////////////////////////// // 武汉探索电脑工作室 // // http://tansuo.51.net // //////////////////////////// //增加规格自定义纸张 //papername: 自定义纸张名称 //paperwidth: 纸张的宽度,以0.1mm为单位 //paperlength: 纸张的高度,以0.1mm为单位 proc......


Delphi实现Singleton模式
单例模式用于限制进程中只有一个某个类的对象,本例的singleton是一个线程实例,在每一个时钟到达时检测是否到达某个时刻(本例的时刻存于ini文件中),如果到达则产生一个线程,但是如果在这个线程完成其任务前又到达一个时钟,则有可能会产生多个线程执行任务,以致出现混乱,所以考虑使用singleton模式解决这个问题(当然还有其他解决方案,但本例使用的是singleton).

核心代码如下: 【程序编程相关:试卷自动生成系统的开发与应用

【推荐阅读:systemparametersinfo

//timer单元 【扩展信息:接口与类的区别

procedure tservice1.timer_maintimer(sender: tobject);

var

mystringlist:tstringlist;

searchrec: tsearchrec;

nowtime :string;

begin

try

datetimetostring(nowtime,hh:nn,now);

if leftstr(nowtime,4)=leftstr(getmsg(game,下发时间,theexename+.ini),4) then

begin

//创建发送线程

global_instance:=tsendthread.getinstance;

//////////////

end;

except

on e: exception do

begin

mystringlist:=tstringlist.create;

if fileexists(extractfilepath(paramstr(0))+err.txt) then

mystringlist.loadfromfile(extractfilepath(paramstr(0))+err.txt);

mystringlist.add((+datetimetostr(now)+)[创建线程出错:]+e.message);

mystringlist.savetofile(extractfilepath(paramstr(0))+err.txt);

mystringlist.free;

if findfirst(extractfilepath(paramstr(0))+err.txt, faanyfile, searchrec)=0 then

begin

if searchrec.size>5000000 then

begin


...   下一页
 ·我对delphi写的几个基类型    »显示摘要«
    摘要: //用惯java或c#的人可能对delphi非常生气,连基本的类型都没有,我平时工作中,经常会曾试着把一些函数集合在一起,也经常做一些属于自己的基础类型的函数,此处把它们弄出来,有不当之处,请大家点评.unit baseclass; interface uses sysutils, classes, strutils, idglobal, math; type tcharset = set......
» 本期热门文章:

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