if you're "crossing" the tracks, you don't have much to worry about as long as you're at least 45* to perpendicular to the tracks. simply unweight the front wheel. the rear wheel can't "turn" into the groove and should follow right over with you. when riding parallel, i just make sure i have enough room to turn my front wheel to about 45* with the tracks, unweight the front, then unweight the rear as i go over.
some secondary advice, make sure you have good speed. the longer your wheel lingers over the groove, the better possibility it has of slipping in. i've crashed once on train tracks because it was raining and i was riding slowly across the tracks. i was kind of distracted and didn't fully unweight the front wheel and didn't anticipate rubber tires on wet steel. as soon as it hit the the rail it just slipped itself sideways right into the groove and i went right over the bars. thankfully i wasn't going fast, and i had a leather jacket on so i just slipped across wet pavement.