Rogues can always enter Stealth outside of combat mode or out of perception-range of foes; in combat, they can hide in shadows if the ranks of nearby creatures are lower than Rogue's stealth rank if they have combat stealth.
If you enter stealth while the target of a monster (such as at the beginning of a fight) the monster will run up to you and do an attack animation to you without damaging you. This can also cause you to automatically retaliate, taking you out of stealth.
If Dual Striking or Rapid Shot is on, a character in stealth might still do a critical hit with the first attack out of stealth. The chance is 100%—your normal critical % for that type of attack, melee or ranged. Basically, the lower your critical rates the better if you want to crit out of stealth with Dual Striking or Rapid Shot on.
Any attack on a living, targetable (i.e., not chickens) target, including using talents or basic attacks will cause the character come out of stealth. Attacking inanimate objects such as barricades does not break stealth.