The only thing the i7-940 has over the i5-2400 is that the i7-940 has a triple-channel memory controller and HyperThreading support. HyperThreading support can be useful for things like video encoding and other highly-parallel capable processes (folding@home, compiling code, video and audio encoders, some compression software like 7Zip). A triple-channel memory controller gives the CPU 150% of the memory transfer bandwidth of a CPU that has a dual-channel memory controller (like the i5-2400). You would have to use three of the same DIMM in order to take advantage of triple-channel memory (triple-channel kits are hard to find and getting harder since these processors are no longer being produced... you would have to buy single DIMMs in threes or find a dual-channel kit and a single DIMM that matches the kit).
When it comes to gaming, neither triple-channel memory nor HyperThreading do anything at all to improve gameplay. You might see marginal benefits using programs like Photoshop (64-bit). I don't know a lot about the first generation Core i series CPUs. Looking over the Intel ARK page for this chip (the i7-940), I don't see Intel VT-d support (probably doesn't at all matter to you, but it comes in handy if you're into virtualization technology). The 940 doesn't support the AES instructions, and it doesn't have the built-in graphics processor. It has a max TDP of 130W, whereas the 2400's max TDP is 95W (45nm vs 32nm processes), so the 940 will run hotter.
The i7-940 was $555 when it was first introduced, while the i5-2400 debuted at only $195. The line of processors that the 940 was a member of were the enthusiast-class series (X58 chipset). The added memory channel is one expensive benefit, but they also have 36 PCI-Express 2.0 lanes. Really, their successor is the Sandy Bridge-E line (X79 chipset). Personally, I would have a hard time deciding between those two chips if they were both offered to me really cheap, but if you just want to build a gaming computer out of them, the i5-2400 would be the absolute best choice. It would give you the opportunity to upgrade later to one of the Ivy Bridge processors if you got the i5-2400 and a Z68 (and performed a BIOS firmware upgrade before upgrading to IB) or Z77 motherboard. If you are doing heavy multitasking or anything that requires a lot of memory bandwidth like RAW digital photo processing or video editing, then the 940 would outperform the 2400, and you would likely be looking to upgrade past Ivy Bridge anyway.