Evaluating $\int_0^{\infty} \frac{\sin x}{x} dx$ with Fubini theorem.

Integrating by parts twice, we get $$ \begin{align} &\int_0^L\sin(x)\,e^{-ax}\,\mathrm{d}x\tag{0}\\ &=-\int_0^L e^{-ax}\,\mathrm{d}\cos(x)\tag{1}\\ &=1-e^{-aL}\cos(L)-a\int_0^L\cos(x)\,e^{-ax}\,\mathrm{d}x\tag{2}\\ &=1-e^{-aL}\cos(L)-a\int_0^L e^{-ax}\,\mathrm{d}\sin(x)\tag{3}\\ &=1-e^{-aL}(\cos(L)+a\sin(L))-a^2\int_0^L\sin(x)\,e^{-ax}\,\mathrm{d}x\tag{4}\\ &=\frac{1-e^{-aL}(\cos(L)+a\sin(L))}{1+a^2}\tag{5} \end{align} $$ Explanation:
$(1)$: prepare to integrate by parts; $u=e^{-ax}$ and $v=\cos(x)$
$(2)$: integrate by parts
$(3)$: prepare to integrate by parts; $u=e^{-ax}$ and $v=\sin(x)$
$(4)$: integrate by parts
$(5)$: add $\frac{a^2}{1+a^2}$ times $(0)$ to $\frac1{1+a^2}$ times $(4)$

Now we can use Fubini $$ \begin{align} \int_0^L\frac{\sin(x)}x\,\mathrm{d}x &=\int_0^L\sin(x)\int_0^\infty e^{-ax}\,\mathrm{d}a\,\mathrm{d}x\tag{6}\\ &=\int_0^\infty\int_0^L\sin(x)\,e^{-ax}\,\mathrm{d}x\,\mathrm{d}a\tag{7}\\ &=\int_0^\infty\frac{1-e^{-aL}(\cos(L)+a\sin(L))}{1+a^2}\,\mathrm{d}a\tag{8}\\[4pt] &=\frac\pi2-\int_0^\infty\frac{L\cos(L)+a\sin(L)}{L^2+a^2}e^{-a}\,\mathrm{d}a\tag{9} \end{align} $$ Explanation:
$(6)$: $\int_0^\infty e^{-ax}\,\mathrm{d}a=\frac1x$
$(7)$: Fubini
$(8)$: apply $(5)$
$(9)$: arctangent integral and substitute $a\mapsto\frac aL$

Then, by Dominated Convergence, we have that $$ \begin{align} \lim_{L\to\infty}\int_0^\infty\left|\frac{L\cos(L)+a\sin(L)}{L^2+a^2}\right|\,e^{-a}\,\mathrm{d}a &\le\lim_{L\to\infty}\int_0^\infty\frac{L+a}{L^2+a^2}\,e^{-a}\,\mathrm{d}a\\[4pt] &=0\tag{10} \end{align} $$ Therefore, combining $(9)$ and $(10)$, we get $$ \bbox[5px,border:2px solid #C0A000]{\lim_{L\to\infty}\int_0^L\frac{\sin(x)}x\,\mathrm{d}x=\frac\pi2}\tag{11} $$


The expression $\int_0^\infty \frac{\sin x}{x} dx$ is an abuse of notation, the precise meaning of this expression should be: $$\lim_{t \to \infty} \int_0^t \frac{\sin x}{x} dx = \frac{\pi}{2} \tag{1}$$ since in fact $x^{-1} \sin x$ is not Lebesgue integrable over $(0, +\infty)$, because its positive and negative parts integrate to $\infty$.

To show $(1)$ using the Fubini's theorem, see, for example, Example $18.4$ of Probability and Measure ($3$rd edition) by Patrick Billingsley.