<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.sarg.dev/index.php?action=history&amp;feed=atom&amp;title=Event-driven_programming</id>
	<title>Event-driven programming - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.sarg.dev/index.php?action=history&amp;feed=atom&amp;title=Event-driven_programming"/>
	<link rel="alternate" type="text/html" href="https://wiki.sarg.dev/index.php?title=Event-driven_programming&amp;action=history"/>
	<updated>2026-04-17T05:47:08Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://wiki.sarg.dev/index.php?title=Event-driven_programming&amp;diff=42002&amp;oldid=prev</id>
		<title>imported&gt;WakingLili: Rewrote for clarity</title>
		<link rel="alternate" type="text/html" href="https://wiki.sarg.dev/index.php?title=Event-driven_programming&amp;diff=42002&amp;oldid=prev"/>
		<updated>2025-10-09T16:49:06Z</updated>

		<summary type="html">&lt;p&gt;Rewrote for clarity&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{short description|Computer programming paradigm}}&lt;br /&gt;
&lt;br /&gt;
In [[computer programming]], &amp;#039;&amp;#039;&amp;#039;event-driven programming&amp;#039;&amp;#039;&amp;#039; is a [[programming paradigm]] in which the [[Control flow|flow of the program]] is determined by external [[Event (computing)|events]]. [[User interface|UI]] events from [[computer mouse|mice]], [[computer keyboard|keyboards]], [[touchpads]] and [[touchscreens]], and external [[sensor]] inputs are common cases. Events may also be programmatically generated, such as from [[message passing|messages from other programs]], notifications from other [[thread (computer science)|threads]], or other [[Computer network|network]] events.&lt;br /&gt;
&lt;br /&gt;
Event-driven programming is the dominant paradigm used in [[graphical user interface]]s applications and network servers.&lt;br /&gt;
&lt;br /&gt;
In an event-driven application, there is generally an [[event loop]] that listens for events and then triggers a [[callback (computer programming)|callback function]] when one of those events is detected.&lt;br /&gt;
&lt;br /&gt;
Event-driven programs can be written in any [[programming language]], although the task is easier in languages that provide [[abstraction (computer science)|high-level abstractions]].&lt;br /&gt;
&lt;br /&gt;
Although they do not exactly fit the event-driven model, [[Interrupt handler|interrupt handling]] and [[exception handling]] have many similarities.&lt;br /&gt;
&lt;br /&gt;
It is important to differentiate between [[Event-driven messaging|event-driven]] and [[Message queue|message-driven (aka queue driven)]] paradigms: Event-driven services (e.g. [[Amazon Simple Notification Service|AWS SNS]]) are decoupled from their consumers. Whereas queue / message driven services (e.g. [[Amazon Simple Queue Service|AWS SQS]]) are coupled with their consumers.&amp;lt;ref&amp;gt;{{Cite book |title=Domain-Driven Design with Java - A Practitioner&amp;#039;s Guide |year=2022 |isbn=9781800564763 |last1=Chandrasekaran |first1=Premanand |last2=Krishnan |first2=Karthik |last3=Ford |first3=Neal |last4=Byars |first4=Brandon |last5=Buijze |first5=Allard |publisher=Packt Publishing }}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Event loop==&lt;br /&gt;
{{Main article|Event loop}}Because the [[main loop|event loop]] that retrieves and dispatches events is common amongst applications, many programming frameworks provide an implementation of an event loop, and the application developer only needs to write the event handlers.  &lt;br /&gt;
&lt;br /&gt;
[[IBM RPG|RPG]], an early programming language from [[IBM]], whose 1960s design concept was similar to event-driven programming discussed above, provided a built-in main [[I/O]] loop (known as the &amp;quot;program cycle&amp;quot;) where the calculations responded in accordance with &amp;quot;indicators&amp;quot; ([[flag (computing)|flags]]) that were set earlier in the cycle. &lt;br /&gt;
&lt;br /&gt;
===Event handlers===&lt;br /&gt;
The actual logic is contained in event handler routines. These routines handle the events to which the main program will respond. For example, a single mouse-click on a &amp;quot;Save&amp;quot; command button in a [[graphical user interface|GUI]] program might trigger a routine to save data to a [[database]]. An &amp;quot;Exit&amp;quot; button might trigger a routine to exit the program. The event loop receives events from all such command buttons and other [[Graphical widget|GUI elements]], dispatching the appropriate event handler routine for each button.&lt;br /&gt;
&lt;br /&gt;
Event handler routines need to be bound to specific events, so the event loop can dispatch the correct routine in response to the event. Many [[Integrated development environment|IDEs]] simplify this process by providing the programmer with an event handling template for each specific event (such as a button click), allowing the programmer to focus on writing the event-handling code.&lt;br /&gt;
&lt;br /&gt;
In a sequential program, keeping track of execution order and history is normally trivial. But in an event-driven program, event handlers execute non-sequentially in response to external events. Special attention and planning is required to correctly structure the event handlers to work when called in any order.&lt;br /&gt;
&lt;br /&gt;
==Common uses==&lt;br /&gt;
Most existing GUI architectures use event-driven programming.&amp;lt;ref name=&amp;quot;Samek&amp;quot;&amp;gt;{{Cite news|url=http://www.ddj.com/cpp/184401643|title=Who Moved My State?|last=Samek|first=Miro|date=April 1, 2013|work=Dr. Dobb&amp;#039;s|access-date=2018-01-28}}&amp;lt;/ref&amp;gt; Windows has an [[Message loop in Microsoft Windows|event loop]]. The Java AWT framework processes all UI changes on a single thread, called the [[Event dispatching thread]]. Similarly, all UI updates in the Java framework [[JavaFX]] occur on the JavaFX Application Thread.&amp;lt;ref&amp;gt;{{cite web&lt;br /&gt;
 |url=https://docs.oracle.com/javafx/2/threads/jfxpub-threads.htm&lt;br /&gt;
 |title=Concurrency in JavaFX&lt;br /&gt;
 |last=Fedortsova&lt;br /&gt;
 |first=Irina&lt;br /&gt;
 |date=June 2012&lt;br /&gt;
 |website=JavaFX Documentation Home&lt;br /&gt;
 |publisher=Oracle&lt;br /&gt;
 |access-date=4 January 2018&lt;br /&gt;
 |quote=The JavaFX scene graph, which represents the graphical user interface of a JavaFX application, is not thread-safe and can only be accessed and modified from the UI thread also known as the JavaFX Application thread. }}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Most network servers and frameworks such as Node.js are also event-driven.&amp;lt;ref&amp;gt;[https://www.digitalocean.com/community/tutorials/nodejs-event-driven-programming/ Event-Driven Programming in Node.js].&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Interrupt and exception handling==&lt;br /&gt;
{{Empty section|date=May 2024}}&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Autonomous peripheral operation]]&lt;br /&gt;
* [[Dataflow programming]]&lt;br /&gt;
* [[DOM events]]&lt;br /&gt;
* [[Event-driven architecture]]&lt;br /&gt;
* [[Event stream processing]] (a similar concept)&lt;br /&gt;
* [[Hardware description language]]&lt;br /&gt;
* [[Interrupt]]&lt;br /&gt;
* [[Inversion of control]]&lt;br /&gt;
* [[Message-oriented middleware]]&lt;br /&gt;
* [[Programming paradigm]]&lt;br /&gt;
* [[Publish–subscribe pattern]]&lt;br /&gt;
* [[Reactor pattern]]&lt;br /&gt;
* [[Signal programming]] (a similar concept)&lt;br /&gt;
* [[Staged event-driven architecture]] (SEDA)&lt;br /&gt;
* [[Time-triggered system]] (an alternative architecture for computer systems)&lt;br /&gt;
* [[Virtual synchrony]], a distributed execution model for event-driven programming&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
*[http://shairosenfeld.com/concurrency.html Concurrency patterns presentation] given at [http://scaleconf.org scaleconf]&lt;br /&gt;
*[https://eventdrivenpgm.sourceforge.net/ Event-Driven Programming: Introduction, Tutorial, History], tutorial by Stephen Ferg&lt;br /&gt;
*[http://www.alan-g.me.uk/l2p/tutevent.htm Event-Driven Programming], tutorial by Alan Gauld&lt;br /&gt;
*[http://www.martinfowler.com/eaaDev/EventCollaboration.html Event Collaboration], article by Martin Fowler&lt;br /&gt;
*[https://web.archive.org/web/20150919021358/https://today.java.net/pub/a/today/2003/10/24/swing.html Rethinking Swing Threading], article by Jonathan Simon&lt;br /&gt;
*[http://www.csse.uwa.edu.au/cnet/eventdriven.html The event-driven programming style] {{Webarchive|url=https://web.archive.org/web/20050220142724/http://www.csse.uwa.edu.au/cnet/eventdriven.html |date=2005-02-20 }}, article by Chris McDonald&lt;br /&gt;
*[https://web.archive.org/web/20050207025012/http://www.codeproject.com/cpp/static-callbacks.asp Event Driven Programming using Template Specialization], article by Christopher Diggins&lt;br /&gt;
*{{Cite book|doi=10.1109/VL.1994.363642|isbn=0-8186-6660-9|chapter=Concepts and architecture of Vista-a multiparadigm programming environment|title=Proceedings of 1994 IEEE Symposium on Visual Languages|year=1994|last1=Schiffer|first1=S.|last2=Frohlich|first2=J.H.|pages=40–47|s2cid=15927869}}&lt;br /&gt;
*[http://docs.eiffel.com/book/method/8-event-driven-programming-and-agents Event-Driven Programming and Agents], chapter&lt;br /&gt;
*[https://archive.today/20121208205239/http://zone.ni.com/devzone/devzone.nsf/webcategories/FCE7EA7ECA51169C862567A9005878EA LabWindows/CVI Resources]&lt;br /&gt;
*[http://www.codeplex.com/pubsub Distributed Publish/Subscribe Event System], an open-source example which is in production on MSN.com and Microsoft.com&lt;br /&gt;
&lt;br /&gt;
{{Programming paradigms navbox}}&lt;br /&gt;
{{Types of programming languages}}&lt;br /&gt;
&lt;br /&gt;
{{DEFAULTSORT:Event-Driven Programming}}&lt;br /&gt;
[[Category:Programming paradigms]]&lt;br /&gt;
[[Category:Events (computing)]]&lt;br /&gt;
[[Category:Articles with example pseudocode]]&lt;/div&gt;</summary>
		<author><name>imported&gt;WakingLili</name></author>
	</entry>
</feed>