multithreading - Periodicall popup form -



multithreading - Periodicall popup form -

i should implement periodically popup form @ other form. popup form isn't mutual design, couldn't utilize standard messages. need implement smoothly showing\hiding of popup form.

now utilize timers hide\show form, have unusual problems. if run show\hide popup form process ok, when seek run other threads @ base of operations form,which marshling vcl thread (math painting) behaviour of popup form become strange.

how should imlement thread-safe popup form @ multi-thread app? thanks

edit

strange thing: timers setup show show hide form period 5s. when process starts ok. popup form show , hide on 5s expecting. got cycles of popup(show popup from) withous pause. 1 time again period of popup ok(5s). timer intervals don't work correctly. agree ~4,6s period. there no periods between popup.

because left out lot of of import info ("form behaving strange" can interpreted in zillion ways, many solutions), i'm going guess problem is, , effort giving solution. please provide relevant info if i'm wrong!

about ttimer:

the ttimer simple solution when need timing signals it's not supposed precise. set timer "fire" @ given interval, , windows send application wm_timer messages configured periodicity. trick here is, there never 2 wm_timer messages on application's queue @ same time.

if create clock, , used ttimer give 1 sec heart-beat, clock on time when computer idle run slow if computer busy. if processes running clock busy clock run slower.

about problem:

you're saying:

if run show\hide popup form process ok, when seek run other threads @ base of operations form,which marshling vcl thread (math painting) behaviour of popup form become strange.

interpretation: assume thread math painting happening somewhere in vcl thread, , that's blocking application's message queue. turn causing application skip wm_timer messages, causing the behaviour of popup form become strange.

possible solutions:

this tough without knowing problem (again, strange - how?), i'm going give ideas way. first of allow me tell you, don't think can prepare problem using improve timer. problem gui related, , gui single-threaded. while have background threads doing stuff, need marshall vcl thread - no matter how precise timer is, can't stop main vcl thread doing marshall thing, timer need wait marshall finish in order needs done.

taking hint i need implement smoothly showing\hiding of popup form assume need number of steps smooth showing\hiding, , that's you're using ttimer for.

if got code this: (warning, pseudo-code, uncertainty compiles)

procedure timer1ontimer(sender:tobject); begin somecounter := somecounter + 1; if somecounter > 10 hidepopupform else setpopupformtransparencyto((somecounter * 255) div 10); end;

replace this:

var hideattime:tdatetime; shownattime:tdatetime; procedure timer1ontimer(sender:tobject); var expectedvisibletime:tdatetime; elapsedvisibletime:tdatetime; begin if > hideattime hidepopupform else begin expectedvisibletime := hideattime - shownattime; elapsedvisibletime := - shownattime; setpopupformtransparencyto(elapsedvisibletime/expectedvisibletime*255); end; end;

the general thought solution compute deadlines, store them in tdatetime variables, compare now ttimer.ontimer; way doesn't matter if timer events don't arrive @ requested intervals, you'd on time else. sure, showing form might not smooth desired, it'll job done.

multithreading delphi forms popup timer

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -