Using the integration of the function $f$ with the prescription $f(z) = \frac{ze^{2iz}}{z^2 + 1}$ along the positively oriented boundary of the region $D = \{ z \in \mathbb{C} \mid |z| \leq R, \operatorname{Im}(z) \geq 0 \}$, where $R \in (1, \infty)$, compute the real integral
$$ \int_{0}^{\infty} \frac{x \sin(2x)}{x^2 + 1} \, dx. $$
Attempt: The boundary consists of the semicircle $|z| = R$ in the upper half-plane and the real interval $[-R, R]$. The function $f(z)$ has simple poles at $z = \pm i$, but only $z = i$ lies within the contour.
Using the residue theorem, the integral around the closed contour is $2\pi i$ times the residue at $z = i$: $$ \text{Res}\left(f(z), i\right) = \lim_{z \to i} (z - i) \frac{z e^{2iz}}{z^2 + 1} = \lim_{z \to i} \frac{z e^{2iz}}{z + i} = \frac{i e^{-2}}{2i} = -\frac{e^{-2}}{2}. $$
Am I on the right path? What can I do from here?