At first, Farquhar feels that it is "not fair" that he should be nearly hanged and nearly drowned and then, ultimately, shot and killed. In his fantasy, he believes that he has fallen into the river, the rope with which he was to be hanged having snapped somewhere above his head; and as he floats toward the water's surface, he refuses to accept the idea that he will die by his enemy's bullets. When Farquhar does reach the surface, he feels as though he possesses a kind of superhuman strength, that his senses have become "preternaturally keen and alert"—in short, that he is incredibly and spectacularly alive.
Eventually, Farquhar reaches the shore and walks, half asleep, through the day and night, while "the thought of his wife and children urged him on." The idea of returning to his family is what pushes him to continue, "despite his suffering": he is in pain, even delirious, and yet he keeps going because he so longs to reach them.
Recall that near the end of part 1, Farquhar had attempted to "fix his last thoughts upon his wife and children" and felt some joy in his belief that his home was still relatively far from enemy lines. In part 3, he imagines his beautiful wife waiting for him at their home, and she reaches out toward him to embrace him with joy. It is, therefore, the thought of his family that keeps him going. This vision of his family is, or course, merely in Farquhar's imagination: right as he imagines reaching his wife, his neck snaps.